lib/pluck_map/presenter.rb in pluck_map-0.1.0 vs lib/pluck_map/presenter.rb in pluck_map-0.2.0

- old
+ new

@@ -20,11 +20,13 @@ define_presenters! end def method_missing(attribute_name, *args, &block) return super if initialized? - attributes.push PluckMap::Attribute.new(attribute_name, args.extract_options!) + options = args.extract_options! + options[:value] = args.first if args.any? + attributes.push PluckMap::Attribute.new(attribute_name, options) :attribute_added end def no_map? attributes.all?(&:no_map?) @@ -75,10 +77,10 @@ def define_to_h! ruby = <<-RUBY def to_h(query) pluck(query) do |results| - results.map { |values| values = Array(values); { #{attributes.map { |attribute| "#{attribute.name.inspect} => #{(attribute.to_ruby(keys))}"}.join(", ")} } } + results.map { |values| values = Array(values); { #{attributes.map { |attribute| "#{attribute.name.inspect} => #{attribute.to_ruby(keys)}"}.join(", ")} } } end end RUBY # puts "\e[34m#{ruby}\e[0m" # <-- helps debugging PluckMapPresenter class_eval ruby, __FILE__, __LINE__ - 7