Class: Waves::Matchers::Query

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

Instance Attribute Summary

Attributes inherited from Base

#constraints

Instance Method Summary collapse

Methods inherited from Base

#[], #test

Constructor Details

#initialize(pattern) ⇒ Query

Returns a new instance of Query.



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

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

Instance Method Details

#call(request) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/matchers/query.rb', line 9

def call( request )
  @pattern.all? do | key, val |
    key = key.to_s
    ( ( val.respond_to?(:call) and val.call( request.query[ key ] ) ) or 
      ( request.query[ key ] and ( ( val == true ) or ( val === request.query[ key ] ) ) ) )
  end
end