Class: Waves::Matchers::Traits

Inherits:
Base show all
Defined in:
lib/matchers/traits.rb

Instance Attribute Summary

Attributes inherited from Base

#constraints

Instance Method Summary collapse

Methods inherited from Base

#[], #test

Constructor Details

#initialize(pattern) ⇒ Traits

Returns a new instance of Traits.



7
# File 'lib/matchers/traits.rb', line 7

def initialize( pattern ) ; @pattern = ( pattern or {} ) ; end

Instance Method Details

#call(request) ⇒ Object



9
10
11
12
13
# File 'lib/matchers/traits.rb', line 9

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