Class: Workflow::Callbacks::TransitionCallbacks::MethodCaller Private

Inherits:
Workflow::Callbacks::TransitionCallback show all
Defined in:
lib/workflow/callbacks/transition_callbacks/method_caller.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A Workflow::Callbacks::TransitionCallback that calls an instance method With arity != 0.

Instance Attribute Summary collapse

Attributes inherited from Workflow::Callbacks::TransitionCallback

#callback_type, #raw_proc

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Workflow::Callbacks::TransitionCallback

#call, #initialize

Constructor Details

This class inherits a constructor from Workflow::Callbacks::TransitionCallback

Instance Attribute Details

#calling_classObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



9
10
11
# File 'lib/workflow/callbacks/transition_callbacks/method_caller.rb', line 9

def calling_class
  @calling_class
end

Class Method Details

.build(callback_type, raw_proc, calling_class) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



26
27
28
29
# File 'lib/workflow/callbacks/transition_callbacks/method_caller.rb', line 26

def build(callback_type, raw_proc, calling_class)
  return raw_proc if zero_arity_method?(raw_proc, calling_class)
  new(callback_type, raw_proc, calling_class)
end

Instance Method Details

#around_proc(target, callbacks) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



18
19
20
21
22
23
# File 'lib/workflow/callbacks/transition_callbacks/method_caller.rb', line 18

def around_proc(target, callbacks)
  transition_context = target.send :transition_context
  method = target.method(raw_proc)
  builder = MethodArgumentBuilder.new(transition_context, method)
  target.send raw_proc, *builder.args, &callbacks
end

#normal_proc(target) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



11
12
13
14
15
16
# File 'lib/workflow/callbacks/transition_callbacks/method_caller.rb', line 11

def normal_proc(target)
  transition_context = target.send :transition_context
  method = target.method(raw_proc)
  builder = MethodArgumentBuilder.new(transition_context, method)
  target.instance_exec(*builder.args, &method)
end