Class: Waves::Matchers::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/matchers/base.rb

Direct Known Subclasses

Accept, ContentType, Path, Query, Request, Traits, URI

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#constraintsObject

Returns the value of attribute constraints.



7
8
9
# File 'lib/matchers/base.rb', line 7

def constraints
  @constraints
end

Instance Method Details

#[](*args) ⇒ Object



9
# File 'lib/matchers/base.rb', line 9

def []( *args ) ; call( *args ) ; end

#test(request) ⇒ Object

used to provide consisting matching logic across all matchers



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/matchers/base.rb', line 12

def test( request )
  constraints.all? do | key, val |
    if val.nil? or val == true
      true
    else
      if val.respond_to? :call
        val.call( request )
      else
        val == request.send( key ) or val === request.send( key ) or request.send( key ) === val
      end
    end
  end
end