Class: MR::FakeRecord::Association

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

Direct Known Subclasses

OneToManyAssociation, OneToOneAssociation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(owner, reflection) ⇒ Association

Returns a new instance of Association.



183
184
185
186
187
# File 'lib/mr/fake_record/associations.rb', line 183

def initialize(owner, reflection)
  @owner = owner
  @reflection = reflection
  @ivar_name = "@#{@reflection.name}"
end

Instance Attribute Details

#owner ⇒ Object (readonly)

ActiveRecord method



181
182
183
# File 'lib/mr/fake_record/associations.rb', line 181

def owner
  @owner
end

#reflection ⇒ Object (readonly)

ActiveRecord method



181
182
183
# File 'lib/mr/fake_record/associations.rb', line 181

def reflection
  @reflection
end

Instance Method Details

#<=>(other) ⇒ Object



197
198
199
# File 'lib/mr/fake_record/associations.rb', line 197

def <=>(other)
  other.kind_of?(Association) ? self.reflection <=> other.reflection : super
end

#klass ⇒ Object

ActiveRecord method



193
194
195
# File 'lib/mr/fake_record/associations.rb', line 193

def klass
  self.reflection.klass
end

#read ⇒ Object

Raises:

  • (NotImplementedError)


189
# File 'lib/mr/fake_record/associations.rb', line 189

def read;         raise NotImplementedError; end

#write(value) ⇒ Object

Raises:

  • (NotImplementedError)


190
# File 'lib/mr/fake_record/associations.rb', line 190

def write(value); raise NotImplementedError; end