Module: Pragma::Operation::Decoration::InstanceMethods
- Defined in:
- lib/pragma/operation/decoration.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#build_decorator(resource) ⇒ Pragma::Decorator::Base
Builds the decorator for the given resource, using the previously defined decorator class.
-
#decorate(decoratable) ⇒ Pragma::Decorator::Base|Object
If a decorator is defined, acts as an alias for #build_decorator.
Instance Method Details
#build_decorator(resource) ⇒ Pragma::Decorator::Base
Builds the decorator for the given resource, using the previously defined decorator class.
This is just an instance-level alias of #build_decorator. You should use this from inside the operation.
47 48 49 50 |
# File 'lib/pragma/operation/decoration.rb', line 47 def build_decorator(resource) resource = resource.to_a if resource.is_a?(Enumerable) compute_decorator_klass.represent(resource) end |
#decorate(decoratable) ⇒ Pragma::Decorator::Base|Object
If a decorator is defined, acts as an alias for #build_decorator. If not, simply returns the provided resource.
59 60 61 62 |
# File 'lib/pragma/operation/decoration.rb', line 59 def decorate(decoratable) return decoratable unless compute_decorator_klass build_decorator(decoratable) end |