lib/cascade/row_processor.rb in cascade-rb-0.2.0 vs lib/cascade/row_processor.rb in cascade-rb-0.2.1
- old
+ new
@@ -12,12 +12,12 @@
define_setting :use_default_presenter, false
define_setting :deafult_presenter, -> { DEFAULT_PROCESSOR }
def initialize(options = {})
+ @options = options
@columns_matching = options[:columns_matching] || ColumnsMatching.new
- @presenters = options.reverse_merge(defined_presenters)
end
# Iterates through object using columns values supported keys as keys for
# iterating, then parse it by curresponding parser.
#
@@ -31,22 +31,29 @@
end
end
private
+ attr_reader :options
+
def receive_presenter(column_name)
- presenter = @presenters[@columns_matching.column_type(column_name)]
+ presenter = presenters[@columns_matching.column_type(column_name)]
if presenter.nil? && !self.class.use_default_presenter
raise Cascade::UnknownPresenterType.new
end
presenter || self.class.deafult_presenter
end
+ def presenters
+ @presenters ||= options.reverse_merge(defined_presenters)
+ end
+
def defined_presenters
{
string: DEFAULT_PROCESSOR,
currency: ComplexFields::Currency.new,
boolean: ComplexFields::Boolean.new,
+ recursive: self.class.new(options)
}
end
end
end