I'm trying to provide an extension to Range that is only valid within the
context of a few classes; however, wrapping it in a module causes kind_of?
to stop identifying ranges as such. Note that this works perfectly if I just
extend Range inside the file, without using a module. What's the difference?
module ExtendRange
class Range
def foo
"bar"
end
end
end
class A
def test
r = (1..10)
[r.kind_of?(Range), r.type == Range, r]
end
end
class B
include ExtendRange
def test
r = (1..10)
[r.kind_of?(Range), r.type == Range, r.type]
end
end
a = A.new
b = B.new
p a.test # => [true, true, Range]
p b.test # => [false, false, Range]
--
Martin DeMello