Module: DuckRecord::Associations::ClassMethods
- Defined in:
- lib/duck_record/associations.rb
Instance Method Summary collapse
- #belongs_to(name, scope = nil, options = {}) ⇒ Object
- #embeds_many(name, options = {}, &extension) ⇒ Object
- #embeds_one(name, options = {}) ⇒ Object
- #has_many(name, scope = nil, options = {}, &extension) ⇒ Object
- #has_one(name, scope = nil, options = {}) ⇒ Object
Instance Method Details
#belongs_to(name, scope = nil, options = {}) ⇒ Object
114 115 116 117 |
# File 'lib/duck_record/associations.rb', line 114 def belongs_to(name, scope = nil, = {}) reflection = Builder::BelongsTo.build(self, name, scope, ) Reflection.add_reflection self, name, reflection end |
#embeds_many(name, options = {}, &extension) ⇒ Object
104 105 106 107 |
# File 'lib/duck_record/associations.rb', line 104 def (name, = {}, &extension) reflection = Builder::EmbedsMany.build(self, name, nil, , &extension) Reflection.add_reflection self, name, reflection end |
#embeds_one(name, options = {}) ⇒ Object
109 110 111 112 |
# File 'lib/duck_record/associations.rb', line 109 def (name, = {}) reflection = Builder::EmbedsOne.build(self, name, nil, ) Reflection.add_reflection self, name, reflection end |
#has_many(name, scope = nil, options = {}, &extension) ⇒ Object
124 125 126 127 |
# File 'lib/duck_record/associations.rb', line 124 def has_many(name, scope = nil, = {}, &extension) reflection = Builder::HasMany.build(self, name, scope, , &extension) Reflection.add_reflection self, name, reflection end |
#has_one(name, scope = nil, options = {}) ⇒ Object
119 120 121 122 |
# File 'lib/duck_record/associations.rb', line 119 def has_one(name, scope = nil, = {}) reflection = Builder::HasOne.build(self, name, scope, ) Reflection.add_reflection self, name, reflection end |