Sha256: 36599f8915d35f27806975b409f643ed98788b6b08a56da70a12ed78e174300b
Contents?: true
Size: 768 Bytes
Versions: 3
Compression:
Stored size: 768 Bytes
Contents
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com # All files in this distribution are subject to the terms of the Ruby license. # This chunk of code redefines the #method method of Kernel to act more # dynamic. module Kernel alias_method :method_get, :method unless defined? method_get # get the object of the method you are currently in or any # other out of the backtrace, as long as it is in the same # instance and retrievable via method_get (which is the old #method). # # class Foo # def bar # method # end # end # # Foo.new.bar #=> #<Method: Foo#bar> def method(n = 0) return method_get(n) unless n.is_a? Integer method_get caller.to_s.scan(/`(.*?)'/)[n].first rescue nil end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ramaze-0.0.9 | lib/ramaze/snippets/kernel/method.rb |
ramaze-0.0.8 | lib/ramaze/snippets/kernel/method.rb |
ramaze-0.1.0 | lib/ramaze/snippets/kernel/method.rb |