Class: Invocation
- Inherits:
-
Object
- Object
- Invocation
- Defined in:
- lib/invocation/invocation.rb,
lib/invocation/controls/no_parameters.rb,
lib/invocation/controls/block_parameter.rb,
lib/invocation/controls/mixed_parameters.rb,
lib/invocation/controls/named_parameters.rb,
lib/invocation/controls/positional_parameters.rb,
lib/invocation/controls/multiple_assignment_parameter.rb,
lib/invocation/controls/multiple_assignment_named_parameter.rb
Defined Under Namespace
Modules: Controls
Instance Attribute Summary collapse
-
#method_name ⇒ Object
readonly
Returns the value of attribute method_name.
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(method_name, parameters) ⇒ Invocation
constructor
A new instance of Invocation.
Constructor Details
#initialize(method_name, parameters) ⇒ Invocation
Returns a new instance of Invocation.
5 6 7 8 |
# File 'lib/invocation/invocation.rb', line 5 def initialize(method_name, parameters) @method_name = method_name @parameters = parameters end |
Instance Attribute Details
#method_name ⇒ Object (readonly)
Returns the value of attribute method_name.
2 3 4 |
# File 'lib/invocation/invocation.rb', line 2 def method_name @method_name end |
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
3 4 5 |
# File 'lib/invocation/invocation.rb', line 3 def parameters @parameters end |
Class Method Details
.build(bndg) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/invocation/invocation.rb', line 10 def self.build(bndg) instance = bndg.receiver method_name = bndg.eval("__method__") mthd = instance.method(method_name) parameters = mthd.parameters parameter_names = parameters.map { |p| p[1] } parameter_values = parameter_names.map { |n| bndg.local_variable_get(n) } params = {} parameter_names.each_with_index do |n, i| params[n] = parameter_values[i] end new(method_name, params) end |