Class: HttpStub::Server::Stub::Controller

Inherits:
Object
  • Object
show all
Defined in:
lib/http_stub/server/stub/controller.rb

Instance Method Summary collapse

Instance Method Details

#find(request, logger) ⇒ Object


15
16
17
# File 'lib/http_stub/server/stub/controller.rb', line 15

def find(request, logger)
  request.session.find_stub(request.parameters[:stub_id], logger)
end

#find_all(request) ⇒ Object


19
20
21
# File 'lib/http_stub/server/stub/controller.rb', line 19

def find_all(request)
  request.session.stubs
end

#match(request, logger) ⇒ Object


7
8
9
10
11
12
13
# File 'lib/http_stub/server/stub/controller.rb', line 7

def match(request, logger)
  stub = request.session.match(request, logger)
  response = stub ? stub.response_for(request) : HttpStub::Server::Response::NOT_FOUND
  request.session.add_match(HttpStub::Server::Stub::Match::Match.new(request, response, stub), logger) if stub
  request.session.add_miss(HttpStub::Server::Stub::Match::Miss.new(request), logger) unless stub
  response
end

#reset(request, logger) ⇒ Object


23
24
25
# File 'lib/http_stub/server/stub/controller.rb', line 23

def reset(request, logger)
  request.session.reset(logger)
end