diff --git a/lib/representable.rb b/lib/representable.rb index d779b9db..6e6ac90b 100644 --- a/lib/representable.rb +++ b/lib/representable.rb @@ -87,7 +87,12 @@ def normalize_options(options) child_options[:wrap] = binding[:wrap] unless binding[:wrap].nil? # nested params: - child_options.merge!(options[binding.name.to_sym]) if options[binding.name.to_sym] + if nested_options = options[binding.name.to_sym] || options[binding.name.to_s] + child_options.merge!(nested_options) + if nested_options.key?("user_options") + child_options[:user_options].merge!(nested_options["user_options"]) + end + end child_options end diff --git a/lib/representable/populator.rb b/lib/representable/populator.rb index db0edb97..85d09577 100644 --- a/lib/representable/populator.rb +++ b/lib/representable/populator.rb @@ -5,14 +5,6 @@ class Populator object_class = binding[:class].(input, options) object = object_class.find_by(id: input["id"]) || object_class.new - if options[:binding].array? - # represented.songs[i] = model - options[:represented].send(binding.getter)[options[:index]] = object - else - # represented.song = model - options[:represented].send(binding.setter, object) - end - object } @@ -23,7 +15,6 @@ def self.apply!(options) options[:parse_pipeline] = ->(input, options) do pipeline = Pipeline[*parse_functions] # TODO: AssignFragment - pipeline = Pipeline::Insert.(pipeline, SetValue, delete: true) # remove the setter function. pipeline = Pipeline::Insert.(pipeline, populator, replace: CreateObject::Populator) # let the actual populator do the job. # puts pipeline.extend(Representable::Pipeline::Debug).inspect pipeline diff --git a/representable.gemspec b/representable.gemspec index d9a34f7c..62e90c66 100644 --- a/representable.gemspec +++ b/representable.gemspec @@ -27,7 +27,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency "rake" spec.add_development_dependency "test_xml", "0.1.6" spec.add_development_dependency "minitest" - spec.add_development_dependency "mongoid" + spec.add_development_dependency "mongoid", "~> 5.1.4" spec.add_development_dependency "virtus" spec.add_development_dependency "json", '>= 1.7.7'