Module: MR::FakeRecord::Associations::ClassMethods

Defined in:
lib/mr/fake_record/associations.rb

Instance Method Summary collapse

Instance Method Details

#belongs_to(name, options = nil) ⇒ Object



23
24
25
# File 'lib/mr/fake_record/associations.rb', line 23

def belongs_to(name, options = nil)
  self.reflections.add_belongs_to(self, name, options)
end

#has_many(name, options = nil) ⇒ Object



31
32
33
# File 'lib/mr/fake_record/associations.rb', line 31

def has_many(name, options = nil)
  self.reflections.add_has_many(self, name, options)
end

#has_one(name, options = nil) ⇒ Object



27
28
29
# File 'lib/mr/fake_record/associations.rb', line 27

def has_one(name, options = nil)
  self.reflections.add_has_one(self, name, options)
end

#reflect_on_all_associations(type = nil) ⇒ Object



41
42
43
# File 'lib/mr/fake_record/associations.rb', line 41

def reflect_on_all_associations(type = nil)
  self.reflections.all(type)
end

#reflect_on_association(name) ⇒ Object

ActiveRecord methods



37
38
39
# File 'lib/mr/fake_record/associations.rb', line 37

def reflect_on_association(name)
  self.reflections.find(name)
end

#reflectionsObject



19
20
21
# File 'lib/mr/fake_record/associations.rb', line 19

def reflections
  @reflections ||= MR::FakeRecord::ReflectionSet.new
end