Sha256: 7f95558b669d46c10a75c25271f3c5d978dbc6bc4e431ae1374a0b862876b331

Contents?: true

Size: 629 Bytes

Versions: 1

Compression:

Stored size: 629 Bytes

Contents

# This monkey patch should not break Ruby compatibility
# but is necessary because MRI, insead 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
    def ===(object)
      object.kind_of?(self)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bogus-0.1.5 lib/bogus/core_ext.rb