Reputation: 15069
After I restructured some files, I'm getting an error. When I call
@batch << Formatter.get(@fields)
it returns @fields
. When I try to use debugger to go into the Formatter.get
method, I see that it is skipped.
I have a directory structure like:
lib/klass/formatter.rb contains:
require 'formatter/formatter'
require 'formatter/foo_formatter'
require 'formatter/bar_formatter'
module Klass
class Formatter
end
end
And lib/klass/formatter/formatter.rb contains:
module Klass
class Formatter
attr_accessor :fields
def self.get fields
case fields[:field_id]
when "foo"; FooFormatter.new fields
when "bar"; BarFormatter.new fields
end
end
lib/klass/formatter/foo_formatter.rb contains:
module Klass
class FooFormatter < Formatter
Upvotes: 0
Views: 65
Reputation: 36576
You will need to change the namespace of lib/klass/formatter/formatter.rb so that it reads
module Klass::Formatter
class Formatter
attr_accessor :fields
def self.get fields
case fields[:field_id]
when "foo"; FooFormatter.new fields
when "bar"; BarFormatter.new fields
end
end
Upvotes: 1