Class: Reflections::Remappers::BelongsTo
- Inherits:
-
Reflections::Remapper
- Object
- Reflections::Remapper
- Reflections::Remappers::BelongsTo
- Defined in:
- lib/reflections/remappers/belongs_to.rb
Constant Summary
Constants inherited from Reflections::Remapper
Reflections::Remapper::REMAPPERS
Instance Attribute Summary collapse
-
#remapper ⇒ Object
readonly
Returns the value of attribute remapper.
Attributes inherited from Reflections::Remapper
Instance Method Summary collapse
Methods inherited from Reflections::Remapper
Constructor Details
This class inherits a constructor from Reflections::Remapper
Instance Attribute Details
#remapper ⇒ Object (readonly)
Returns the value of attribute remapper.
5 6 7 |
# File 'lib/reflections/remappers/belongs_to.rb', line 5 def remapper @remapper end |
Instance Method Details
#remap(ar_classes, &block) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/reflections/remappers/belongs_to.rb', line 7 def remap(ar_classes, &block) ar_classes.each do |ar_class| associations_for_class(ar_class).each do |association| foreign_key = association.foreign_key || "#{association.name}_id" ar_class.where(foreign_key => from_obj).each do |record| update_record_or_yield record, association, &block end end end end |