Class: Monolens::Type::Responding
- Inherits:
-
Object
- Object
- Monolens::Type::Responding
- Includes:
- ErrorHandling
- Defined in:
- lib/monolens/type/responding.rb
Class Method Summary collapse
Instance Method Summary collapse
- #===(instance) ⇒ Object
- #dress(instance, registry, &block) ⇒ Object
-
#initialize(messages) ⇒ Responding
constructor
A new instance of Responding.
Methods included from ErrorHandling
Constructor Details
#initialize(messages) ⇒ Responding
Returns a new instance of Responding.
6 7 8 |
# File 'lib/monolens/type/responding.rb', line 6 def initialize() @messages = end |
Class Method Details
.to(*messages) ⇒ Object
10 11 12 |
# File 'lib/monolens/type/responding.rb', line 10 def self.to(*) new() end |
Instance Method Details
#===(instance) ⇒ Object
20 21 22 |
# File 'lib/monolens/type/responding.rb', line 20 def ===(instance) @messages.all?{|m| instance.respond_to?(m) } end |
#dress(instance, registry, &block) ⇒ Object
14 15 16 17 18 |
# File 'lib/monolens/type/responding.rb', line 14 def dress(instance, registry, &block) fail!("Invalid #{instance}", &block) unless self === instance instance end |