Class: Cognizant::Process::Triggers::Transition

Inherits:
Trigger
  • Object
show all
Defined in:
lib/cognizant/process/triggers/transition.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}, &block) ⇒ Transition

Returns a new instance of Transition.


5
6
7
8
9
# File 'lib/cognizant/process/triggers/transition.rb', line 5

def initialize(options = {}, &block)
  @from = [*options[:from]]
  @to = [*options[:to]]
  @do = block
end

Instance Method Details

#notify(transition) ⇒ Object


11
12
13
14
15
# File 'lib/cognizant/process/triggers/transition.rb', line 11

def notify(transition)
  if @from.include?(transition.from_name) and @to.include?(transition.to_name)
    @do.call(@delegate.process) if @do and @do.respond_to?(:call)
  end
end

#reset!Object


17
18
# File 'lib/cognizant/process/triggers/transition.rb', line 17

def reset!
end