Class: PactBroker::ApplicationContext

Inherits:
Object
  • Object
show all
Defined in:
lib/pact_broker/application_context.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ ApplicationContext

Returns a new instance of ApplicationContext.



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/pact_broker/application_context.rb', line 14

def initialize(params)
  @decorator_configuration = params[:decorator_configuration]
  @api_contract_configuration = params[:api_contract_configuration]
  @decorator_context_creator = params[:decorator_context_creator]
  @webhook_execution_configuration_creator = params[:webhook_execution_configuration_creator]
  @resource_authorizer = params[:resource_authorizer]
  @before_resource = params[:before_resource]
  @after_resource = params[:after_resource]
  @error_logger = params[:error_logger]
  @error_reporter = params[:error_reporter]
  @error_response_generator = params[:error_response_generator]
end

Instance Attribute Details

#after_resourceObject (readonly)

Returns the value of attribute after_resource.



3
4
5
# File 'lib/pact_broker/application_context.rb', line 3

def after_resource
  @after_resource
end

#api_contract_configurationObject (readonly)

Returns the value of attribute api_contract_configuration.



3
4
5
# File 'lib/pact_broker/application_context.rb', line 3

def api_contract_configuration
  @api_contract_configuration
end

#before_resourceObject (readonly)

Returns the value of attribute before_resource.



3
4
5
# File 'lib/pact_broker/application_context.rb', line 3

def before_resource
  @before_resource
end

#decorator_configurationObject (readonly)

Returns the value of attribute decorator_configuration.



3
4
5
# File 'lib/pact_broker/application_context.rb', line 3

def decorator_configuration
  @decorator_configuration
end

#decorator_context_creatorObject (readonly)

Returns the value of attribute decorator_context_creator.



3
4
5
# File 'lib/pact_broker/application_context.rb', line 3

def decorator_context_creator
  @decorator_context_creator
end

#error_loggerObject (readonly)

Returns the value of attribute error_logger.



3
4
5
# File 'lib/pact_broker/application_context.rb', line 3

def error_logger
  @error_logger
end

#error_reporterObject (readonly)

Returns the value of attribute error_reporter.



3
4
5
# File 'lib/pact_broker/application_context.rb', line 3

def error_reporter
  @error_reporter
end

#error_response_generatorObject (readonly)

Returns the value of attribute error_response_generator.



3
4
5
# File 'lib/pact_broker/application_context.rb', line 3

def error_response_generator
  @error_response_generator
end

#resource_authorizerObject (readonly)

Returns the value of attribute resource_authorizer.



3
4
5
# File 'lib/pact_broker/application_context.rb', line 3

def resource_authorizer
  @resource_authorizer
end

#webhook_execution_configuration_creatorObject (readonly)

Returns the value of attribute webhook_execution_configuration_creator.



3
4
5
# File 'lib/pact_broker/application_context.rb', line 3

def webhook_execution_configuration_creator
  @webhook_execution_configuration_creator
end

Class Method Details

.default_application_context(overrides = {}) ⇒ Object

TODO pass in configuration



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/pact_broker/application_context.rb', line 28

def self.default_application_context(overrides = {})
  require "pact_broker/api/decorators/configuration"
  require "pact_broker/api/contracts/configuration"
  require "pact_broker/api/decorators/decorator_context_creator"
  require "pact_broker/webhooks/execution_configuration_creator"
  require "pact_broker/errors/error_logger"
  require "pact_broker/errors/error_reporter"
  require "pact_broker/api/resources/error_response_generator"

  params = {
    decorator_configuration: PactBroker::Api::Decorators::Configuration.default_configuration,
    api_contract_configuration: PactBroker::Api::Contracts::Configuration.default_configuration,
    decorator_context_creator: PactBroker::Api::Decorators::DecoratorContextCreator,
    webhook_execution_configuration_creator: PactBroker::Webhooks::ExecutionConfigurationCreator,
    error_logger: PactBroker::Errors::ErrorLogger,
    error_reporter: PactBroker::Errors::ErrorReporter.new(PactBroker.configuration.api_error_reporters),
    error_response_generator: PactBroker::Api::Resources::ErrorResponseGenerator,
  }.merge(overrides)

  ApplicationContext.new(params)
end