Class: Wallaby::DecoratorFinder

Inherits:
ClassFinder show all
Defined in:
lib/services/wallaby/decorator_finder.rb

Direct Known Subclasses

AuthorizerFinder

Instance Attribute Summary

Attributes inherited from ClassFinder

#current_controller_class, #model_class, #script_name

Instance Method Summary collapse

Instance Method Details

#executeClass

Find decorator class by script name and model class from the following places:

  • #controller_class‘s #resource_decorator

  • possible decorator class built from script name and model class, e.g. /admin and Order::Item will give us the possible decorators:

    • Admin::Order::ItemDecorator

    • Order::ItemDecorator

    • ItemDecorator

  • #controller_class‘s default #application_decorator

Returns:

  • (Class)

    decorator class



17
18
19
20
21
# File 'lib/services/wallaby/decorator_finder.rb', line 17

def execute
  controller_class.resource_decorator ||
    possible_default_class ||
    controller_class.application_decorator
end