Class: Bumbleworks::EntityInteractor

Inherits:
Participant show all
Defined in:
lib/bumbleworks/participants/entity_interactor.rb

Instance Method Summary collapse

Methods inherited from Participant

#on_cancel

Methods included from WorkitemEntityStorage

#entity_storage_workitem, #wrapped_workitem

Instance Method Details

#call_method(method_name, options = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/bumbleworks/participants/entity_interactor.rb', line 14

def call_method(method_name, options = {})
  result = if options[:args]
    options[:args] = [options[:args]] if options[:args].is_a?(Hash)
    entity.send(method_name, *options[:args])
  else
    entity.send(method_name)
  end
  if result && options[:save_as]
    workitem.fields[options[:save_as]] = result
  end
  result
end

#on_workitemObject



3
4
5
6
7
8
9
10
11
12
# File 'lib/bumbleworks/participants/entity_interactor.rb', line 3

def on_workitem
  method_name = workitem.fields['params']['method'] ||
    workitem.fields['params']['to'] ||
    workitem.fields['params']['for']
  result_field = workitem.fields['params']['and_save_as']
  arguments = workitem.fields['params']['arguments'] ||
    workitem.fields['params']['with']
  result = call_method(method_name, :save_as => result_field, :args => arguments)
  reply
end