Class: Representable::Populator
- Inherits:
-
Object
- Object
- Representable::Populator
- Defined in:
- lib/representable/populator.rb
Constant Summary collapse
- FindOrInstantiate =
->(input, ) { binding = [:binding] object_class = binding[:class].(input, ) object = object_class.find_by(id: input["id"]) || object_class.new if [:binding].array? # represented.songs[i] = model [:represented].send(binding.getter)[[:index]] = object else # represented.song = model [:represented].send(binding.setter, object) end object }
Class Method Summary collapse
-
.apply!(options) ⇒ Object
pipeline: [StopOnExcluded, AssignName, ReadFragment, StopOnNotFound, OverwriteOnNil, AssignFragment, #<Representable::Function::CreateObject:0x9805a44>, #<Representable::Function::Decorate:0x9805a1c>, Deserialize, Set].
Class Method Details
.apply!(options) ⇒ Object
pipeline: [StopOnExcluded, AssignName, ReadFragment, StopOnNotFound, OverwriteOnNil, AssignFragment, #<Representable::Function::CreateObject:0x9805a44>, #<Representable::Function::Decorate:0x9805a1c>, Deserialize, Set]
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/representable/populator.rb', line 21 def self.apply!() return unless populator = [:populator] [:parse_pipeline] = ->(_input, _opts) 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 end end |