C
Clifford Heath
I have the following code using facets/basicobject with 1.8,
and want to know what the equivalent would be for 1.9:
class Real < BasicObject
def initialize(r)
@__value = r.to_f
end
define_method
class) { __self__.class }
def send(meth, *a, &b)
# Ensure that normal sends go to __self__, not @__value
__self__.send(meth, *a, &b)
end
private
def method_missing(meth, *args, &block)
@__value.send meth, *args, &block
end
end
(and similar, defining Int for integers).
This seems to be ok with 1.8, but 1.9 doesn't have __self__.
Any thoughts?
Clifford Heath.
and want to know what the equivalent would be for 1.9:
class Real < BasicObject
def initialize(r)
@__value = r.to_f
end
define_method
def send(meth, *a, &b)
# Ensure that normal sends go to __self__, not @__value
__self__.send(meth, *a, &b)
end
private
def method_missing(meth, *args, &block)
@__value.send meth, *args, &block
end
end
(and similar, defining Int for integers).
This seems to be ok with 1.8, but 1.9 doesn't have __self__.
Any thoughts?
Clifford Heath.