Class: XDry::BeforeReturnIP

Inherits:
InsertionPoint show all
Defined in:
lib/xdry/patching/insertion_points.rb

Instance Attribute Summary

Attributes inherited from InsertionPoint

#ip, #method, #node

Instance Method Summary collapse

Methods inherited from InsertionPoint

#found?, #insert

Constructor Details

#initialize(scope) ⇒ BeforeReturnIP

Returns a new instance of BeforeReturnIP.



122
123
124
125
# File 'lib/xdry/patching/insertion_points.rb', line 122

def initialize scope
  @scope = scope
  super()
end

Instance Method Details

#find!Object



127
128
129
130
131
132
133
134
# File 'lib/xdry/patching/insertion_points.rb', line 127

def find!
  child_node = @scope.children.find { |child| child.is_a? NReturn }
  if child_node.nil?
    before @scope.ending_node
  else
    before child_node
  end
end