This file contains 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
1 class Object | |
2 # Returns a hash where the key is a message that this object | |
3 # responds to and the value is the first object that responded | |
4 # to that message. | |
5 def first_responders | |
6 methods_hash = {} | |
7 self.class.instance_methods.each {|m| methods_hash[m] = self} | |
8 self.class.ancestors.each do |ancestor| | |
9 ancestor.instance_methods.each {|m| methods_hash[m] = ancestor} | |
10 end |
NewerOlder