Class: Workflow::Event::Conditions

Inherits:
Object
  • Object
show all
Defined in:
lib/workflow/event.rb

Overview

:nodoc:#

Instance Method Summary collapse

Constructor Details

#initialize(**options, &block) ⇒ Conditions

Returns a new instance of Conditions.



48
49
50
51
52
53
# File 'lib/workflow/event.rb', line 48

def initialize(**options, &block)
  @if      = Array(options[:if])
  @unless  = Array(options[:unless])
  @if      << block if block_given?
  @conditions_lambdas = conditions_lambdas
end

Instance Method Details

#apply?(target) ⇒ Boolean

Returns:

  • (Boolean)


59
60
61
62
# File 'lib/workflow/event.rb', line 59

def apply?(target)
  # TODO: Remove the second parameter from the conditions below.
  @conditions_lambdas.all?{|l| l.call(target, ->(){})}
end

#inspectObject



55
56
57
# File 'lib/workflow/event.rb', line 55

def inspect
  "if: #{@if}, unless: #{@unless}"
end