Module: Tramway::Decorators::AssocDecoratorHelper

Defined in:
lib/tramway/decorators/association.rb

Overview

Helper module for association decorators

Class Method Summary collapse

Class Method Details

.decorate_associated_object(assoc) ⇒ Object



45
46
47
# File 'lib/tramway/decorators/association.rb', line 45

def decorate_associated_object(assoc)
  decorator(assoc.class).decorate(assoc)
end

.decorate_has_many_association(assoc) ⇒ Object



41
42
43
# File 'lib/tramway/decorators/association.rb', line 41

def decorate_has_many_association(assoc)
  assoc.empty? ? [] : decorator(assoc.klass).decorate(assoc)
end

.decorator(class_name) ⇒ Object



49
50
51
# File 'lib/tramway/decorators/association.rb', line 49

def decorator(class_name)
  Tramway::Decorators::NameBuilder.default_decorator_class_name(class_name).constantize
end