Module: DumbDelegator::TripleEqualExt
- Defined in:
- lib/dumb_delegator/triple_equal_ext.rb
Overview
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.
target = MyAwesomeClass.new dummy = DumbDelegator.new(target)
MyAwesomeClass === dummy #=> false DumbDelegator === dummy #=> true
MyAwesomeClass.extend(DumbDelegator::TripleEqualExt)
MyAwesomeClass === dummy #=> true DumbDelegator === dummy #=> true
Instance Method Summary collapse
-
#===(other) ⇒ Boolean
Case equality for the extended Class/Module and then given
other
.
Instance Method Details
#===(other) ⇒ Boolean
Case equality for the extended Class/Module and then given other
.
27 28 29 |
# File 'lib/dumb_delegator/triple_equal_ext.rb', line 27 def ===(other) super || other.is_a?(self) end |