Class: Sbmt::Pact::Provider::ProviderStateServlet
- Inherits:
-
WEBrick::HTTPServlet::ProcHandler
- Object
- WEBrick::HTTPServlet::ProcHandler
- Sbmt::Pact::Provider::ProviderStateServlet
- Defined in:
- lib/sbmt/pact/provider/provider_state_servlet.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
- #add_setup_state(name, use_before_setup_hook, &block) ⇒ Object
- #add_teardown_state(name, use_after_teardown_hook, &block) ⇒ Object
- #after_teardown(&block) ⇒ Object
- #before_setup(&block) ⇒ Object
-
#initialize(logger: Logger.new($stdout)) ⇒ ProviderStateServlet
constructor
A new instance of ProviderStateServlet.
Constructor Details
#initialize(logger: Logger.new($stdout)) ⇒ ProviderStateServlet
Returns a new instance of ProviderStateServlet.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/sbmt/pact/provider/provider_state_servlet.rb', line 11 def initialize(logger: Logger.new($stdout)) super(build_proc) @logger = logger @provider_setup_states = {} @provider_teardown_states = {} @before_setup_hook_proc = nil @after_teardown_hook_proc = nil @global_setup_hook = ::Sbmt::Pact.configuration.before_provider_state_proc @global_teardown_hook = ::Sbmt::Pact.configuration.after_provider_state_proc end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
9 10 11 |
# File 'lib/sbmt/pact/provider/provider_state_servlet.rb', line 9 def logger @logger end |
Instance Method Details
#add_setup_state(name, use_before_setup_hook, &block) ⇒ Object
26 27 28 29 30 |
# File 'lib/sbmt/pact/provider/provider_state_servlet.rb', line 26 def add_setup_state(name, use_before_setup_hook, &block) raise "provider state #{name} already configured" if @provider_setup_states[name].present? @provider_setup_states[name] = {proc: block, use_hooks: use_before_setup_hook} end |
#add_teardown_state(name, use_after_teardown_hook, &block) ⇒ Object
32 33 34 35 36 |
# File 'lib/sbmt/pact/provider/provider_state_servlet.rb', line 32 def add_teardown_state(name, use_after_teardown_hook, &block) raise "provider state #{name} already configured" if @provider_teardown_states[name].present? @provider_teardown_states[name] = {proc: block, use_hooks: use_after_teardown_hook} end |
#after_teardown(&block) ⇒ Object
42 43 44 |
# File 'lib/sbmt/pact/provider/provider_state_servlet.rb', line 42 def after_teardown(&block) @after_teardown_hook_proc = block end |
#before_setup(&block) ⇒ Object
38 39 40 |
# File 'lib/sbmt/pact/provider/provider_state_servlet.rb', line 38 def before_setup(&block) @before_setup_hook_proc = block end |