module DumbDelegator::TripleEqualExt

This optional extension enables a Class/Module to support case statements.

Specifically, it monkey-patches a Class/Module's +:===+ method to check if the other argument is an instance of the extended Class/Module.

@example Extending a Class/Module to handle class equality for a DumbDelegator instance.

target = MyAwesomeClass.new dummy = DumbDelegator.new(target)

MyAwesomeClass === dummy #=> false DumbDelegator === dummy #=> true

MyAwesomeClass.extend(DumbDelegator::TripleEqualExt)

MyAwesomeClass === dummy #=> true DumbDelegator === dummy #=> true

Public Instance Methods

===(other) click to toggle source

Case equality for the extended Class/Module and then given other.

@param other [Object] An instance of any Object

@return [Boolean] If the other is an instance of the Class/Module.

Calls superclass method
# File lib/dumb_delegator/triple_equal_ext.rb, line 25
def ===(other)
  super || other.is_a?(self)
end