Class: Pact::MockService::RequestHandlers::BaseAdministrationRequestHandler

Inherits:
BaseRequestHandler
  • Object
show all
Defined in:
lib/pact/mock_service/request_handlers/base_administration_request_handler.rb

Constant Summary

Constants inherited from BaseRequestHandler

Pact::MockService::RequestHandlers::BaseRequestHandler::NOT_FOUND_RESPONSE

Constants included from Consumer::RackRequestHelper

Consumer::RackRequestHelper::REQUEST_KEYS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseRequestHandler

#call, #json_response, #text_response

Methods included from Consumer::RackRequestHelper

#params_hash, #request_as_hash_from

Constructor Details

#initialize(name, logger) ⇒ BaseAdministrationRequestHandler

Returns a new instance of BaseAdministrationRequestHandler.



11
12
13
14
# File 'lib/pact/mock_service/request_handlers/base_administration_request_handler.rb', line 11

def initialize name, logger
  @name = name
  @logger = logger
end

Instance Attribute Details

#loggerObject

Returns the value of attribute logger.



9
10
11
# File 'lib/pact/mock_service/request_handlers/base_administration_request_handler.rb', line 9

def logger
  @logger
end

#nameObject

Returns the value of attribute name.



9
10
11
# File 'lib/pact/mock_service/request_handlers/base_administration_request_handler.rb', line 9

def name
  @name
end

Instance Method Details

#has_mock_service_header?(env) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/pact/mock_service/request_handlers/base_administration_request_handler.rb', line 20

def has_mock_service_header? env
  env['HTTP_X_PACT_MOCK_SERVICE']
end

#match?(env) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/pact/mock_service/request_handlers/base_administration_request_handler.rb', line 16

def match? env
  has_mock_service_header?(env) && path_matches?(env) && method_matches?(env)
end

#method_matches?(env) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/pact/mock_service/request_handlers/base_administration_request_handler.rb', line 28

def method_matches? env
  env['REQUEST_METHOD'] == request_method
end

#path_matches?(env) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/pact/mock_service/request_handlers/base_administration_request_handler.rb', line 24

def path_matches? env
  env['PATH_INFO'].chomp("/") == request_path
end

#request_methodObject

Raises:

  • (NotImplementedError)


36
37
38
# File 'lib/pact/mock_service/request_handlers/base_administration_request_handler.rb', line 36

def request_method
  raise NotImplementedError
end

#request_pathObject

Raises:

  • (NotImplementedError)


32
33
34
# File 'lib/pact/mock_service/request_handlers/base_administration_request_handler.rb', line 32

def request_path
  raise NotImplementedError
end