Sam Smoot
6/16/2007 2:57:00 AM
Uhmm, yeah. Nevermind that version. Perfection!:
> require 'parse_tree'
>
> class UnboundMethod
>
> def binding_class
> @class_name || @class_name = begin
> to_s =~ /\#\<UnboundMethod\:\s(\w+)/
> Object.const_get($1)
> end
> end
>
> def name
> @name || @name = begin
> to_s =~ /\#\<UnboundMethod\:\s\w+\#(\w+)/
> $1.freeze
> end
> end
>
> def parameters
> @parameters || @parameters = begin
> ParseTree.new.parse_tree_for_method(binding_class, name)[2][1][1][1..-1]
> end
> end
>
> end
Now any UnboundMethod (written in Ruby) can be inspected for it's
parameters, without any fancy require hacks...