class Bumbleworks::EntityInteractor

Public Instance Methods

call_method(method_name, options = {}) click to toggle source
# 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_workitem() click to toggle source
# 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