Module: Masterman::Associations
- Included in:
- Base
- Defined in:
- lib/masterman/associations.rb
Instance Method Summary collapse
- #association(name, instance) ⇒ Object
- #belongs_to(name, scope = nil, options = {}) ⇒ Object
- #has_many(name, scope = nil, options = {}) ⇒ Object
- #has_one(name, scope = nil, options = {}) ⇒ Object
Instance Method Details
#association(name, instance) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/masterman/associations.rb', line 15 def association(name, instance) association = association_instance_get(name) if association.nil? reflection = self._reflections[name] association = reflection.build_association(instance, reflection) association_instance_set(name, association) end association end |
#belongs_to(name, scope = nil, options = {}) ⇒ Object
3 4 5 |
# File 'lib/masterman/associations.rb', line 3 def belongs_to(name, scope = nil, = {}) build_reflection_and_add(:belongs_to, name, scope, ) end |
#has_many(name, scope = nil, options = {}) ⇒ Object
7 8 9 |
# File 'lib/masterman/associations.rb', line 7 def has_many(name, scope = nil, = {}) build_reflection_and_add(:has_many, name, scope, ) end |
#has_one(name, scope = nil, options = {}) ⇒ Object
11 12 13 |
# File 'lib/masterman/associations.rb', line 11 def has_one(name, scope = nil, = {}) build_reflection_and_add(:has_one, name, scope, ) end |