Skip to content

Instantly share code, notes, and snippets.

@bernerdschaefer
Created December 17, 2014 00:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bernerdschaefer/327e4c633f982cc79665 to your computer and use it in GitHub Desktop.
Save bernerdschaefer/327e4c633f982cc79665 to your computer and use it in GitHub Desktop.
class << self
alias mess_with_bernerd define_method
end
mess_with_bernerd(:foo) do
#
#
#
end
def find_method(file, line)
methods.
map { |m| method(m) }.
reject { |m| !m.source_location }.
select { |m| m.source_location[0] == file }.
select { |m| m.source_location[1] <= line }.
sort_by { |m| m.source_location[1] }.
last.
name
end
if $0 == __FILE__
puts "Don't mess with Bernerd"
puts find_method(__FILE__, 7)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment