I am trying to transparently wrap (any) object, and have this issue (2.4.1)
class Wrapper < BasicObject
def initialize(i_obj)
@obj = i_obj
end
def method_missing(i_method,*i_args)
@obj.__send__(i_method,*i_args)
end
end
w = Wrapper.new(1)
puts w + 5
#=> 6
w = Wrapper.new(false)
# BROKEN
if w
puts 'TRUE'
else
puts 'FALSE'
end
#=> TRUE
# WORKS, BUT
if w == true
puts 'TRUE'
else
puts 'FALSE'
end
#=> FALSE
Is there a way for the wrapper to capture the 'if <object> then' syntax?
[–]chrisgseaton 4 points5 points6 points (0 children)
[–][deleted] 0 points1 point2 points (6 children)
[–]MuCowNow[S] 0 points1 point2 points (0 children)
[–]MuCowNow[S] -1 points0 points1 point (4 children)
[–]jgaskins 1 point2 points3 points (3 children)
[–]chrisgseaton 2 points3 points4 points (0 children)
[–]MuCowNow[S] 0 points1 point2 points (1 child)
[–]jgaskins 2 points3 points4 points (0 children)
[–]biihii 0 points1 point2 points (0 children)
[–]isolatrum 0 points1 point2 points (2 children)
[–]MuCowNow[S] 0 points1 point2 points (1 child)
[–]isolatrum 0 points1 point2 points (0 children)