From 67675b4bb5fe837968c582a18a12cc4cc0ca802f Mon Sep 17 00:00:00 2001 From: John Mair Date: Wed, 16 Mar 2011 18:25:04 +1300 Subject: version 0.4.0, added proper support for immediate values to source_location in 1.8. --- lib/method_source/source_location.rb | 14 ++++++++++++++ lib/method_source/version.rb | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/method_source/source_location.rb b/lib/method_source/source_location.rb index f1929e1..e018d74 100644 --- a/lib/method_source/source_location.rb +++ b/lib/method_source/source_location.rb @@ -44,6 +44,20 @@ module MethodSource Class.new { include(method_owner) } end + # deal with immediate values + case + when klass == Symbol + return :a.method(name).source_location + when klass == Fixnum + return 0.method(name).source_location + when klass == TrueClass + return true.method(name).source_location + when klass == FalseClass + return false.method(name).source_location + when klass == NilClass + return nil.method(name).source_location + end + begin klass.allocate.method(name).source_location rescue TypeError diff --git a/lib/method_source/version.rb b/lib/method_source/version.rb index 05234be..56956e7 100644 --- a/lib/method_source/version.rb +++ b/lib/method_source/version.rb @@ -1,3 +1,3 @@ module MethodSource - VERSION = "0.3.5" + VERSION = "0.4.0" end -- cgit v1.2.1