Class: MR::FakeRecord::PolymorphicBelongsToAssociation

Inherits:
BelongsToAssociation show all
Defined in:
lib/mr/fake_record/associations.rb

Instance Attribute Summary

Attributes inherited from Association

#owner, #reflection

Instance Method Summary collapse

Methods inherited from OneToOneAssociation

#read, #write

Methods inherited from Association

#<=>, #initialize, #read, #write

Constructor Details

This class inherits a constructor from MR::FakeRecord::Association

Instance Method Details

#klass ⇒ Object



248
249
250
251
# File 'lib/mr/fake_record/associations.rb', line 248

def klass
  class_name = @owner.send(self.reflection.foreign_type)
  class_name.constantize if class_name
end

#write_attributes(associated_fake_record) ⇒ Object



242
243
244
245
246
# File 'lib/mr/fake_record/associations.rb', line 242

def write_attributes(associated_fake_record)
  super
  associated_type = associated_fake_record.class.name
  @owner.send("#{self.reflection.foreign_type}=", associated_type)
end