Class: Copyable::Declarations::Associations
- Inherits:
-
Declaration
- Object
- Declaration
- Copyable::Declarations::Associations
- Defined in:
- lib/copyable/declarations/associations.rb
Class Method Summary collapse
-
.execute(association_list, original_model, new_model, global_override = {}, skip_validations, skip_associations) ⇒ Object
this is the algorithm for copying associated records according to the instructions given in the copyable declaration.
Methods inherited from Declaration
Class Method Details
.execute(association_list, original_model, new_model, global_override = {}, skip_validations, skip_associations) ⇒ Object
this is the algorithm for copying associated records according to the instructions given in the copyable declaration
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/copyable/declarations/associations.rb', line 9 def execute(association_list, original_model, new_model, global_override = {}, skip_validations, skip_associations) @skip_validations = skip_validations @skip_associations = skip_associations @global_override = global_override association_list.each do |assoc_name, advice| association = original_model.class.reflections[assoc_name.to_s] check_advice(association, advice, original_model) unless advice == :do_not_copy || skip_associations.include?(assoc_name.to_sym) copy_association(association, original_model, new_model) end end end |