Class: Ocelot::Processor::ArrayRule
- Inherits:
-
Rules::Rule
- Object
- Base
- Rules::Rule
- Ocelot::Processor::ArrayRule
- Includes:
- Ocelot
- Defined in:
- lib/ocelot/processor.rb
Instance Method Summary collapse
Methods included from Ocelot
in?, obj_to_s, remove_callbacks, safely
Methods inherited from Rules::Rule
#relationships, #save_to_db, #use_source_db!, #use_target_db!
Methods inherited from Base
#connection, #in?, #logger, #obj_to_s, #remove_callbacks, #safely
Instance Method Details
#save(obj, array, assoc, c) ⇒ Object
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/ocelot/processor.rb', line 187 def save(obj, array, assoc, c) safely obj, assoc.name do c.process_filter(:obj => obj, :collection => array, :name => assoc.name).each do |val| unless in? c.saved, val use_source_db! inspect_level = c.process_rule(:obj => val, :caller => obj_to_s(obj)) yield val, inspect_level end use_target_db! if assoc.is_a? ActiveRecord::Reflection::ThroughReflection safely assoc.through_reflection.klass, assoc.name, val do c.process_rule :obj => assoc.through_reflection.klass.new, :src => obj, :target => val, :caller => obj_to_s(obj,assoc) end end end end end |