Class: DissociatedIntrospection::MethodInLiner::InLiner
- Inherits:
-
Parser::TreeRewriter
- Object
- Parser::TreeRewriter
- DissociatedIntrospection::MethodInLiner::InLiner
- Defined in:
- lib/dissociated_introspection/method_in_liner.rb
Instance Attribute Summary collapse
-
#defs ⇒ Object
Returns the value of attribute defs.
Instance Method Summary collapse
- #called_method(method_name) ⇒ Object
- #called_on_self?(called_on) ⇒ Boolean
- #in_line_calls(node) ⇒ Object
- #on_send(node) ⇒ Object
Instance Attribute Details
#defs ⇒ Object
Returns the value of attribute defs.
20 21 22 |
# File 'lib/dissociated_introspection/method_in_liner.rb', line 20 def defs @defs end |
Instance Method Details
#called_method(method_name) ⇒ Object
44 45 46 |
# File 'lib/dissociated_introspection/method_in_liner.rb', line 44 def called_method(method_name) defs.detect { |_def| _def.name == method_name } end |
#called_on_self?(called_on) ⇒ Boolean
40 41 42 |
# File 'lib/dissociated_introspection/method_in_liner.rb', line 40 def called_on_self?(called_on) called_on.nil? || called_on.type == :self end |
#in_line_calls(node) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/dissociated_introspection/method_in_liner.rb', line 30 def in_line_calls(node) called_on, method_name, *args = *node # TODO: Deal with args by replacing lvar with passed objects return unless args.empty? && called_on_self?(called_on) called_method = called_method(method_name) return unless called_method processed_called_method = process(called_method.body.ast) node.updated(processed_called_method.type, processed_called_method.children) end |
#on_send(node) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/dissociated_introspection/method_in_liner.rb', line 22 def on_send(node) if (result = in_line_calls(node)) result else super end end |