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

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

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#decorator(klass = nil) { ... } ⇒ Object

Sets the decorator to use for decorating this operation.

Parameters:

  • klass (Class) (defaults to: nil)

    a subclass of Pragma::Decorator::Base

Yields:

  • A block which will be called with the operation’s context which should return the decorator class. The block can also return nil if decoration should be skipped.



20
21
22
23
24
25
26
# File 'lib/pragma/operation/decoration.rb', line 20

def decorator(klass = nil, &block)
  if !klass && !block_given?
    fail ArgumentError, 'You must pass either a decorator class or a block'
  end

  @decorator = klass || block
end

#decorator_klassClass

Returns the decorator class.

Returns:

  • (Class)


31
32
33
# File 'lib/pragma/operation/decoration.rb', line 31

def decorator_klass
  @decorator
end