Class: Invocation
- Inherits:
-
Object
- Object
- Invocation
- Defined in:
- lib/record_invocation/invocation.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#method_name ⇒ Object
readonly
Returns the value of attribute method_name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(method_name, arguments) ⇒ Invocation
constructor
A new instance of Invocation.
Constructor Details
#initialize(method_name, arguments) ⇒ Invocation
Returns a new instance of Invocation.
5 6 7 8 |
# File 'lib/record_invocation/invocation.rb', line 5 def initialize(method_name, arguments) @method_name = method_name @arguments = arguments end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
3 4 5 |
# File 'lib/record_invocation/invocation.rb', line 3 def arguments @arguments end |
#method_name ⇒ Object (readonly)
Returns the value of attribute method_name.
2 3 4 |
# File 'lib/record_invocation/invocation.rb', line 2 def method_name @method_name 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/record_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] } argument_values = parameter_names.map { |n| bndg.local_variable_get(n) } params = {} parameter_names.each_with_index do |n, i| params[n] = argument_values[i] end new(method_name, params) end |