Technology Agnostic Rubyist : Open Source Lights The Way

Thursday, January 17, 2013

instance.method(:split).source_location

Discover monkey-patched code by invoking source_location via IRB,
r = 'some string'
r.method(:split).source_location
 => nil # String.split method code is not monkey patched

Then, via IRB
r = 'some string'
class String
  def split(e)
    puts 'what?'
  end
end
r.method(:split).source_location
 => what?
 => ["(irb)", 38] # Now I know where the method lives!

Reference, The split is not enough whitespace shenanigans for rubyists



Tweets

Contributors