Class: Workflow::Callbacks::TransitionCallback::MethodArgumentBuilder Private
- Inherits:
-
Object
- Object
- Workflow::Callbacks::TransitionCallback::MethodArgumentBuilder
- Defined in:
- lib/workflow/callbacks/transition_callback.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.
Builds arguments appropriate for calling the wrapped proc or method.
Instance Attribute Summary collapse
- #args ⇒ Object readonly private
- #attributes ⇒ Object readonly private
- #event ⇒ Object readonly private
- #event_args ⇒ Object readonly private
- #from ⇒ Object readonly private
- #method ⇒ Object readonly private
- #to ⇒ Object readonly private
- #transition_context ⇒ Object readonly private
Instance Method Summary collapse
- #build_args ⇒ Object private
-
#initialize(transition_context, method) ⇒ MethodArgumentBuilder
constructor
private
A new instance of MethodArgumentBuilder.
- #keyrest_arguments ⇒ Object private
- #keyrest_param ⇒ Object private
- #keyword_arguments ⇒ Object private
- #kw_params ⇒ Object private
- #name_arguments ⇒ Object private
- #name_params ⇒ Object private
-
#parameters ⇒ Array
private
Parameter definition for the object.
- #params_by_type(*types) ⇒ Object private
- #rest_arguments ⇒ Object private
- #rest_param ⇒ Object private
Constructor Details
#initialize(transition_context, method) ⇒ MethodArgumentBuilder
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.
Returns a new instance of MethodArgumentBuilder.
50 51 52 53 54 55 |
# File 'lib/workflow/callbacks/transition_callback.rb', line 50 def initialize(transition_context, method) @transition_context = transition_context @method = method @from, @to, @event, @event_args, @attributes = transition_context.values build_args end |
Instance Attribute Details
#args ⇒ Object (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.
49 50 51 |
# File 'lib/workflow/callbacks/transition_callback.rb', line 49 def args @args end |
#attributes ⇒ Object (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.
48 49 50 |
# File 'lib/workflow/callbacks/transition_callback.rb', line 48 def attributes @attributes end |
#event ⇒ Object (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.
48 49 50 |
# File 'lib/workflow/callbacks/transition_callback.rb', line 48 def event @event end |
#event_args ⇒ Object (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.
48 49 50 |
# File 'lib/workflow/callbacks/transition_callback.rb', line 48 def event_args @event_args end |
#from ⇒ Object (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.
48 49 50 |
# File 'lib/workflow/callbacks/transition_callback.rb', line 48 def from @from end |
#method ⇒ Object (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.
48 49 50 |
# File 'lib/workflow/callbacks/transition_callback.rb', line 48 def method @method end |
#to ⇒ Object (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.
48 49 50 |
# File 'lib/workflow/callbacks/transition_callback.rb', line 48 def to @to end |
#transition_context ⇒ Object (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.
48 49 50 |
# File 'lib/workflow/callbacks/transition_callback.rb', line 48 def transition_context @transition_context end |
Instance Method Details
#build_args ⇒ 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.
57 58 59 60 61 |
# File 'lib/workflow/callbacks/transition_callback.rb', line 57 def build_args @args = name_arguments + rest_arguments kwargs = keyword_arguments.merge(keyrest_arguments) @args << kwargs unless kwargs.empty? end |
#keyrest_arguments ⇒ 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.
88 89 90 91 92 93 94 |
# File 'lib/workflow/callbacks/transition_callback.rb', line 88 def keyrest_arguments if keyrest_param attributes else {} end end |
#keyrest_param ⇒ 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.
104 105 106 |
# File 'lib/workflow/callbacks/transition_callback.rb', line 104 def keyrest_param params_by_type(:keyrest).first end |
#keyword_arguments ⇒ 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.
82 83 84 85 86 |
# File 'lib/workflow/callbacks/transition_callback.rb', line 82 def keyword_arguments kw_params.map do |name| [name, attributes.delete(name)] end.to_h end |
#kw_params ⇒ 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.
100 101 102 |
# File 'lib/workflow/callbacks/transition_callback.rb', line 100 def kw_params params_by_type :keyreq, :keyopt end |
#name_arguments ⇒ 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.
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/workflow/callbacks/transition_callback.rb', line 63 def name_arguments name_params.map do |name| case name when :to then to when :from then from when :event then event else (attributes.delete(name) || event_args.shift) end end end |
#name_params ⇒ 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.
96 97 98 |
# File 'lib/workflow/callbacks/transition_callback.rb', line 96 def name_params params_by_type :opt, :req end |
#parameters ⇒ Array
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.
Parameter definition for the object. See UnboundMethod#parameters
121 122 123 |
# File 'lib/workflow/callbacks/transition_callback.rb', line 121 def parameters method.parameters end |
#params_by_type(*types) ⇒ 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.
112 113 114 115 116 |
# File 'lib/workflow/callbacks/transition_callback.rb', line 112 def params_by_type(*types) parameters.select do |type, _name| types.include? type end.map(&:last) end |
#rest_arguments ⇒ 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.
74 75 76 77 78 79 80 |
# File 'lib/workflow/callbacks/transition_callback.rb', line 74 def rest_arguments if rest_param event_args else [] end end |
#rest_param ⇒ 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.
108 109 110 |
# File 'lib/workflow/callbacks/transition_callback.rb', line 108 def rest_param params_by_type(:rest).first end |