Class: Waves::Matchers::Traits
Overview
TODO:
Umm.. what all can exist here? –rue
Instance Method Summary collapse
-
#[](request) ⇒ Object
Proc-like interface.
- #call(request) ⇒ Object
-
#initialize(pattern) ⇒ Traits
constructor
A new instance of Traits.
Constructor Details
#initialize(pattern) ⇒ Traits
Returns a new instance of Traits.
8 9 10 11 |
# File 'lib/waves/matchers/traits.rb', line 8 def initialize(pattern) raise ArgumentError, "No traits given!" unless pattern @pattern = pattern end |
Instance Method Details
#[](request) ⇒ Object
Proc-like interface
21 22 23 |
# File 'lib/waves/matchers/traits.rb', line 21 def [](request) call request end |
#call(request) ⇒ Object
13 14 15 16 17 |
# File 'lib/waves/matchers/traits.rb', line 13 def call( request ) @pattern.all? do | key, val | ( val.is_a? Proc and val.call( request.traits[ key ] ) ) or val === request.traits[ key ] end end |