Module: Superstore::Associations::ClassOverrides
- Defined in:
- lib/superstore/associations.rb
Instance Method Summary collapse
-
#belongs_to(name, **options) ⇒ Object
Options [:class_name] Use if the class cannot be inferred from the association [:polymorphic] Specify if the association is polymorphic Example: class Driver < Superstore::Base end class Truck < Superstore::Base end.
- #belongs_to_required_by_default ⇒ Object
- #has_many(name, **options) ⇒ Object
- #has_one(name, **options) ⇒ Object
Instance Method Details
#belongs_to(name, **options) ⇒ Object
Options
- :class_name
-
Use if the class cannot be inferred from the association
- :polymorphic
-
Specify if the association is polymorphic
Example:
class Driver < Superstore::Base
end
class Truck < Superstore::Base
end
21 22 23 24 25 26 27 |
# File 'lib/superstore/associations.rb', line 21 def belongs_to(name, **) if .delete(:superstore) Superstore::Associations::Builder::BelongsTo.build(self, name, ) else super end end |
#belongs_to_required_by_default ⇒ Object
45 46 47 |
# File 'lib/superstore/associations.rb', line 45 def belongs_to_required_by_default false end |
#has_many(name, **options) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/superstore/associations.rb', line 29 def has_many(name, **) if .delete(:superstore) Superstore::Associations::Builder::HasMany.build(self, name, ) else super end end |
#has_one(name, **options) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/superstore/associations.rb', line 37 def has_one(name, **) if .delete(:superstore) Superstore::Associations::Builder::HasOne.build(self, name, ) else super end end |