Sha256: 6265294e06ce90831b471d715bf744554dc17c0b5de631b3fe97cd9c27a9024b
Contents?: true
Size: 835 Bytes
Versions: 10
Compression:
Stored size: 835 Bytes
Contents
## # Taken from ruby2ruby, Copyright (c) 2006 Ryan Davis under the MIT License require 'parse_tree' require 'unique' require 'sexp_processor' class Method def with_class_and_method_name if self.inspect =~ /<Method: (.*)\#(.*)>/ then klass = eval $1 method = $2.intern raise "Couldn't determine class from #{self.inspect}" if klass.nil? return yield(klass, method) else raise "Can't parse signature: #{self.inspect}" end end def to_sexp with_class_and_method_name do |klass, method| ParseTree.new(false).parse_tree_for_method(klass, method) end end end class Proc def to_method Unique.send(:define_method, :proc_to_method, self) Unique.new.method(:proc_to_method) end def to_sexp body = self.to_method.to_sexp[2][1..-1] [:proc, *body] end end
Version data entries
10 entries across 10 versions & 2 rubygems