Module: MR::FakeRecord::Associations::ClassMethods
- Defined in:
- lib/mr/fake_record/associations.rb
Instance Method Summary collapse
- #belongs_to(name, options = nil) ⇒ Object
- #has_many(name, options = nil) ⇒ Object
- #has_one(name, options = nil) ⇒ Object
- #reflect_on_all_associations(type = nil) ⇒ Object
-
#reflect_on_association(name) ⇒ Object
ActiveRecord methods.
- #reflections ⇒ Object
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, = nil) self.reflections.add_belongs_to(self, name, ) end |
#has_many(name, options = nil) ⇒ Object
31 32 33 |
# File 'lib/mr/fake_record/associations.rb', line 31 def has_many(name, = nil) self.reflections.add_has_many(self, name, ) end |
#has_one(name, options = nil) ⇒ Object
27 28 29 |
# File 'lib/mr/fake_record/associations.rb', line 27 def has_one(name, = nil) self.reflections.add_has_one(self, name, ) 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 |
#reflections ⇒ Object
19 20 21 |
# File 'lib/mr/fake_record/associations.rb', line 19 def reflections @reflections ||= MR::FakeRecord::ReflectionSet.new end |