123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
# File 'lib/method_trace.rb', line 123
def definition
@definition ||= begin
if source.is_a?(Class)
source.class_hierarchy.each do |cls|
d = MethodTrace::MethodDefinition.definition_sites["#{cls.object_id}::#{self.name}"]
@from = cls and return d if d
end
else
d = MethodTrace::MethodDefinition.definition_sites["#{source.object_id}::#{self.name}"]
@from = 'singleton' and return d if d
end
source.class.class_hierarchy.each do |cls|
d = MethodTrace::MethodDefinition.definition_sites["#{cls.object_id}##{self.name}"]
@from = cls and return d if d
end
source.usable_modules.each do |mod|
d = MethodTrace::MethodDefinition.definition_sites["#{mod.object_id}##{self.name}"]
@from = mod and return d if d
end
['unknown']
end
end
|