Class: Waves::Matchers::Request

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

Instance Attribute Summary

Attributes inherited from Base

#constraints

Instance Method Summary collapse

Methods inherited from Base

#[], #test

Constructor Details

#initialize(options) ⇒ Request

Returns a new instance of Request.



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

def initialize( options )
  @uri = Matchers::URI.new( options )
  @constraints = {
    :content_type => Matchers::ContentType.new( options[ :content_type ] ),
    :accept => Matchers::Accept.new( options ),
    :query => Matchers::Query.new( options[:query] ),
    :traits => Matchers::Traits.new( options[:traits] )
  }
end

Instance Method Details

#call(request) ⇒ Object



17
18
19
20
21
# File 'lib/matchers/request.rb', line 17

def call( request )
  if test( request ) and captured = @uri[ request ]
    request.traits.waves.captured = captured
  end
end