Class: ProcessEngine::Listener::Base

Inherits:
Object
  • Object
show all
Defined in:
app/models/process_engine/listener/base.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(process_task, listener) ⇒ Base

Returns a new instance of Base.



4
5
6
7
# File 'app/models/process_engine/listener/base.rb', line 4

def initialize(process_task, listener)
  @process_task = process_task
  @listener = listener
end

Instance Attribute Details

#listenerObject (readonly)

Returns the value of attribute listener.



2
3
4
# File 'app/models/process_engine/listener/base.rb', line 2

def listener
  @listener
end

#process_taskObject (readonly)

Returns the value of attribute process_task.



2
3
4
# File 'app/models/process_engine/listener/base.rb', line 2

def process_task
  @process_task
end

Class Method Details

.execute(process_task, listeners, event) ⇒ Object



9
10
11
# File 'app/models/process_engine/listener/base.rb', line 9

def self.execute(process_task, listeners, event)
  listeners.select { |ln| ln[:event] == event}.each { |listener| new(process_task, listener).execute }
end

Instance Method Details

#executeObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/models/process_engine/listener/base.rb', line 13

def execute
  listener_type = listener[:type]

  case listener_type
  when "class_name"
    execute_class_name
  when "delegate_expression"
    execute_delegate_expression
  when "expression"
    execute_expression
  when "script"
    execute_script
  else
    raise "No such type (#{listener_type}) supported"
  end
end