Module: Tramway::Decorators::AssociationClassMethods
- Included in:
- BaseDecorator
- Defined in:
- lib/tramway/decorators/association.rb
Overview
Module for defining association class-level methods
Instance Method Summary collapse
-
#association(association) ⇒ Object
has_and_belongs_to_many is not supported for now.
- #associations(*associations) ⇒ Object
Instance Method Details
#association(association) ⇒ Object
has_and_belongs_to_many is not supported for now
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/tramway/decorators/association.rb', line 25 def association(association) define_method(association) do assoc = object.send(association) if assoc.is_a?(ActiveRecord::Relation) AssocDecoratorHelper.decorate_has_many_association assoc elsif assoc.present? AssocDecoratorHelper.decorate_associated_object(assoc) end end end |
#associations(*associations) ⇒ Object
18 19 20 21 22 |
# File 'lib/tramway/decorators/association.rb', line 18 def associations(*associations) associations.each do |assoc| association assoc end end |