Sha256: 0cb5744d02d26762097cc2053a1b3f52130c9818c6a8470607c6cfd2ade908ba
Contents?: true
Size: 778 Bytes
Versions: 2
Compression:
Stored size: 778 Bytes
Contents
# This monkey patch should not break Ruby compatibility # but is necessary because MRI, instead of calling object.kind_of?(module), # calls the C function, which implements kind_of. This makes # using fake objects in switch cases produce unexpected results: # # fake = fake(:library) { Library } # # case fake # when Library then "bingo!" # else raise "oh noes!" # end # # Without the patch, the snippet above raises 'oh noes!' # instead of returning 'bingo!'. class Module # don't warn about redefining === method Bogus::Support.supress_warnings do alias :__trequals__ :=== def ===(object) # BasicObjects do not have kind_of? method return __trequals__(object) unless Object.__trequals__(object) object.kind_of?(self) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bogus-0.1.7 | lib/bogus/core_ext.rb |
bogus-0.1.6 | lib/bogus/core_ext.rb |