Class: HttpStub::Server::Request::Factory

Inherits:
Object
  • Object
show all
Defined in:
lib/http_stub/server/request/factory.rb

Instance Method Summary collapse

Constructor Details

#initialize(session_identifier_setting, server_memory) ⇒ Factory

Returns a new instance of Factory.


7
8
9
10
# File 'lib/http_stub/server/request/factory.rb', line 7

def initialize(session_identifier_setting, server_memory)
  @session_identifier_strategy = HttpStub::Server::Session::IdentifierStrategy.new(session_identifier_setting)
  @server_memory               = server_memory
end

Instance Method Details

#create(rack_request, sinatra_parameters, logger) ⇒ Object


12
13
14
15
16
17
# File 'lib/http_stub/server/request/factory.rb', line 12

def create(rack_request, sinatra_parameters, logger)
  sinatra_request = HttpStub::Server::Request::SinatraRequest.new(rack_request, sinatra_parameters)
  session_id      = @session_identifier_strategy.identifier_for(sinatra_request)
  session         = @server_memory.session_registry.find_or_create(session_id, logger)
  HttpStub::Server::Request::Request.new(sinatra_request, session_id, session)
end