Class: DissociatedIntrospection::MethodCall
- Inherits:
-
Object
- Object
- DissociatedIntrospection::MethodCall
- Defined in:
- lib/dissociated_introspection/method_call.rb
Defined Under Namespace
Classes: Argument
Instance Attribute Summary collapse
-
#ruby_code ⇒ Object
readonly
Returns the value of attribute ruby_code.
Instance Method Summary collapse
- #arguments ⇒ Object
-
#initialize(ruby_code) ⇒ MethodCall
constructor
A new instance of MethodCall.
- #name ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(ruby_code) ⇒ MethodCall
Returns a new instance of MethodCall.
25 26 27 |
# File 'lib/dissociated_introspection/method_call.rb', line 25 def initialize(ruby_code) @ruby_code = ruby_code end |
Instance Attribute Details
#ruby_code ⇒ Object (readonly)
Returns the value of attribute ruby_code.
23 24 25 |
# File 'lib/dissociated_introspection/method_call.rb', line 23 def ruby_code @ruby_code end |
Instance Method Details
#arguments ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/dissociated_introspection/method_call.rb', line 29 def arguments ruby_code.ast.children[2..-1].map do |c| case c.type when :sym, :str c.to_a.first when :block Lambda.new(c) else c end end end |
#name ⇒ Object
42 43 44 |
# File 'lib/dissociated_introspection/method_call.rb', line 42 def name ruby_code.ast.children[1] end |
#to_h ⇒ Object
46 47 48 |
# File 'lib/dissociated_introspection/method_call.rb', line 46 def to_h { name: name, arguments: arguments } end |