T
Trans
another issue:
5) Doesn't encapsulate the original object.
I can offer a solution to that, though it still suffers some of the
other problems. I haven't tested this but it should work (and if not,
it can be fixed to do so):
require 'facets/more/namespace'
class Object
namespace :meta do
def send(obj, meth, *args)
Object.instance_methodsend).bind(obj).call(meth, *args)
end
def class(obj)
Object.instance_methodclass).bind(obj).call
end
# etc
end
end
class Foo
def send(*args)
"whoo!"
end
def class
"stupid!"
end
end
f = Foo.new
puts f.class # stupid!
puts f.meta.class # Foo
puts f.sendobject_id) # whoo!
puts f.sendmeta).sendobject_id) # -605608944
T.
5) Doesn't encapsulate the original object.
I can offer a solution to that, though it still suffers some of the
other problems. I haven't tested this but it should work (and if not,
it can be fixed to do so):
require 'facets/more/namespace'
class Object
namespace :meta do
def send(obj, meth, *args)
Object.instance_methodsend).bind(obj).call(meth, *args)
end
def class(obj)
Object.instance_methodclass).bind(obj).call
end
# etc
end
end
class Foo
def send(*args)
"whoo!"
end
def class
"stupid!"
end
end
f = Foo.new
puts f.class # stupid!
puts f.meta.class # Foo
puts f.sendobject_id) # whoo!
puts f.sendmeta).sendobject_id) # -605608944
T.