Module: Pragma::Operation::Decoration::ClassMethods

Defined in:
lib/pragma/operation/decoration.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#build_decorator(resource) ⇒ Pragma::Decorator::Base

Builds the decorator for the given resource, using the previously defined decorator class.

Works with both singular resources and collections.

Parameters:

  • resource (Object)

Returns:

  • (Pragma::Decorator::Base)

See Also:



37
38
39
# File 'lib/pragma/operation/decoration.rb', line 37

def build_decorator(resource)
  decorator_klass.represent(resource)
end

#decorator(klass) ⇒ Object

Sets the decorator to use for validating this operation.

Parameters:

  • klass (Class)

    a subclass of Pragma::Decorator::Base



17
18
19
# File 'lib/pragma/operation/decoration.rb', line 17

def decorator(klass)
  @decorator = klass
end

#decorator_klassClass

Returns the decorator class.

Returns:

  • (Class)


24
25
26
# File 'lib/pragma/operation/decoration.rb', line 24

def decorator_klass
  @decorator
end