Class: Module
- Defined in:
- lib/abstractivator/lazy.rb,
lib/abstractivator/module_ext.rb
Instance Method Summary collapse
-
#===(obj) ⇒ Object
To enable case/when support, reimplement Module#=== so it goes through our method_missing mechanism.
-
#type? ⇒ Boolean
useful in the following scenario: things.select(&:Array.type?) instead of: things.select { |x| x.is_a?(Array) }.
Instance Method Details
#===(obj) ⇒ Object
To enable case/when support, reimplement Module#=== so it goes through our method_missing mechanism. See github.com/ruby/ruby/blob/v2_3_0/object.c#L1534
88 89 90 |
# File 'lib/abstractivator/lazy.rb', line 88 def ===(obj) obj.is_a?(self) end |
#type? ⇒ Boolean
useful in the following scenario:
things.select(&:Array.type?)
instead of:
things.select { |x| x.is_a?(Array) }
6 7 8 |
# File 'lib/abstractivator/module_ext.rb', line 6 def type? proc { |x| x.is_a?(self) } end |