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
6
7
8
9
# File 'lib/eye/process/trigger.rb', line 3

def add_triggers
  if self[:triggers]
    self[:triggers].each do |type, cfg|
      add_trigger(cfg)
    end
  end
end

#check_triggers(transition) ⇒ Object


15
16
17
# File 'lib/eye/process/trigger.rb', line 15

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

#conditional_startObject

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


20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/eye/process/trigger.rb', line 20

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

  previous_reason = state_reason
  if last_scheduled_reason && previous_reason && last_scheduled_reason.class != previous_reason.class
    warn "skip, last_scheduled_reason(#{last_scheduled_reason.inspect}) != previous_reason(#{previous_reason})"
    return
  end

  start
end

#remove_triggersObject


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

def remove_triggers
  self.triggers = []
end