Module: Switchman::ActiveRecord::ForeignAssociation
- Defined in:
- lib/switchman/active_record/association.rb
Instance Method Summary collapse
-
#set_owner_attributes(record) ⇒ Object
significant change: * transpose the key to the correct shard.
Instance Method Details
#set_owner_attributes(record) ⇒ Object
significant change:
* transpose the key to the correct shard
62 63 64 65 66 67 68 69 70 |
# File 'lib/switchman/active_record/association.rb', line 62 def set_owner_attributes(record) # rubocop:disable Naming/AccessorMethodName return if [:through] key = owner._read_attribute(reflection.join_foreign_key) key = Shard.relative_id_for(key, owner.shard, shard) record._write_attribute(reflection.join_primary_key, key) record._write_attribute(reflection.type, owner.class.polymorphic_name) if reflection.type end |