module Rung::Runner::CallHelper
Public Class Methods
call(action, state, operation_instance, action_from_block = false, second_argument = nil, &block)
click to toggle source
# File lib/rung/runner/call_helper.rb, line 6 def call(action, state, operation_instance, action_from_block = false, second_argument = nil, &block) raise Error, "Can't pass block when action_from_block is enabled" if block && action_from_block runnable = to_runnable(action, operation_instance) arity = runnable.arity if action_from_block case arity when 0 operation_instance.instance_exec(&runnable) when 1 operation_instance.instance_exec(state, &runnable) else operation_instance.instance_exec(state, second_argument, &runnable) end else case arity when 0 runnable.call(&block) when 1 runnable.call(state, &block) else runnable.call(state, second_argument, &block) end end end
Private Class Methods
to_runnable(action, operation_instance)
click to toggle source
# File lib/rung/runner/call_helper.rb, line 35 def to_runnable(action, operation_instance) case action when Symbol, String operation_instance.method(action) when Proc action else action.method(:call) end rescue NameError action end