Module: Eye::Process::Trigger

Included in:
Eye::Process
Defined in:
lib/eye/process/trigger.rb

Instance Method Summary collapse

Instance Method Details

#add_triggersObject



3
4
5
# File 'lib/eye/process/trigger.rb', line 3

def add_triggers
  (self[:triggers] || {}).each_value { |cfg| add_trigger(cfg) }
end

#check_triggers(transition) ⇒ Object



11
12
13
# File 'lib/eye/process/trigger.rb', line 11

def check_triggers(transition)
  self.triggers.each { |trigger| trigger.notify(transition, @state_call) }
end

#conditional_startObject

conditional start, used in triggers, to start only from unmonitored state, and only if special reason



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/eye/process/trigger.rb', line 16

def conditional_start
  unless unmonitored?
    warn "skip, because in state #{state_name}"
    return
  end

  state_by = @state_call.try(:[], :by)
  current_by = @scheduled_call.try(:[], :by)
  if state_by && current_by && state_by != current_by
    warn "skip, state_by(#{state_by}) != current_by(#{current_by})"
    return
  end

  start
end

#remove_triggersObject



7
8
9
# File 'lib/eye/process/trigger.rb', line 7

def remove_triggers
  self.triggers = []
end