Skip to content

Commit

Permalink
Merge pull request banister#10 from ConradIrwin/master
Browse files Browse the repository at this point in the history
Fix method_source in the case that the method method has been overridden on 1.8.7
  • Loading branch information
banister committed Feb 28, 2012
2 parents 3577133 + 1da46f4 commit 67754ab
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/method_source/source_location.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,14 @@ def source_location
end

begin
klass.allocate.method(name).source_location
Object.instance_method(:method).bind(klass.allocate).call(name).source_location
rescue TypeError

# Assume we are dealing with a Singleton Class:
# 1. Get the instance object
# 2. Forward the source_location lookup to the instance
instance ||= ObjectSpace.each_object(owner).first
instance.method(name).source_location
Object.instance_method(:method).bind(instance).call(name).source_location
end
end
end
Expand Down

0 comments on commit 67754ab

Please sign in to comment.