Created
December 17, 2014 00:47
-
-
Save bernerdschaefer/327e4c633f982cc79665 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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