Class: RespondTo

Inherits:
Object show all
Defined in:
lib/y_support/misc/respond_to.rb

Overview

RespondTo class for easy use of respond_to? in case statements.

Constant Summary collapse

Matchers =
{}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method) ⇒ RespondTo

Returns a new instance of RespondTo.



9
# File 'lib/y_support/misc/respond_to.rb', line 9

def initialize method; @method = method end

Instance Attribute Details

#methodObject (readonly)

Returns the value of attribute method.



7
8
9
# File 'lib/y_support/misc/respond_to.rb', line 7

def method
  @method
end

Class Method Details

.create(method) ⇒ Object



8
# File 'lib/y_support/misc/respond_to.rb', line 8

def self.create method; Matchers[ method ] ||= new method end

Instance Method Details

#===(obj) ⇒ Object



10
# File 'lib/y_support/misc/respond_to.rb', line 10

def === obj; obj.respond_to? method end