Module: Pragma::Decorator::Association::ClassMethods
- Defined in:
- lib/pragma/decorator/association.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#associations ⇒ Hash{Symbol => Reflection}
Returns the associations defined on this decorator.
-
#belongs_to(property_name, options = {}) ⇒ Object
Defines a
belongs_to
association on this decorator. -
#has_one(property_name, options = {}) ⇒ Object
Defines a
has_one
association on this decorator.
Instance Method Details
#associations ⇒ Hash{Symbol => Reflection}
Returns the associations defined on this decorator.
31 32 33 |
# File 'lib/pragma/decorator/association.rb', line 31 def associations @associations ||= {} end |
#belongs_to(property_name, options = {}) ⇒ Object
Defines a belongs_to
association on this decorator.
This will first create an association definition and then define a new property with the name of the association.
This method supports all the usual options accepted by #property
.
44 45 46 |
# File 'lib/pragma/decorator/association.rb', line 44 def belongs_to(property_name, = {}) define_association :belongs_to, property_name, end |
#has_one(property_name, options = {}) ⇒ Object
Defines a has_one
association on this decorator.
This will first create an association definition and then define a new property with the name of the association.
This method supports all the usual options accepted by #property
.
57 58 59 |
# File 'lib/pragma/decorator/association.rb', line 57 def has_one(property_name, = {}) # rubocop:disable Naming/PredicateName define_association :has_one, property_name, end |