Class: MR::FakeRecord::OneToManyAssociation

Inherits:
Association
  • Object
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 Association

#<=>, #initialize, #klass

Constructor Details

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

Instance Method Details

#readObject



223
224
225
226
# File 'lib/mr/fake_record/associations.rb', line 223

def read
  @owner.instance_variable_get(@ivar_name) ||
  @owner.instance_variable_set(@ivar_name, [])
end

#write(value) ⇒ Object



228
229
230
# File 'lib/mr/fake_record/associations.rb', line 228

def write(value)
  @owner.instance_variable_set(@ivar_name, [*value].compact)
end