Class: Alchemrest::FaradayMiddleware::KillSwitch
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Alchemrest::FaradayMiddleware::KillSwitch
- Defined in:
- lib/alchemrest/faraday_middleware/kill_switch.rb
Instance Attribute Summary collapse
-
#service_name ⇒ Object
readonly
Returns the value of attribute service_name.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ KillSwitch
constructor
A new instance of KillSwitch.
Constructor Details
#initialize(app, options = {}) ⇒ KillSwitch
Returns a new instance of KillSwitch.
8 9 10 11 |
# File 'lib/alchemrest/faraday_middleware/kill_switch.rb', line 8 def initialize(app, = {}) @service_name = .fetch(:service_name) super(app) end |
Instance Attribute Details
#service_name ⇒ Object (readonly)
Returns the value of attribute service_name.
6 7 8 |
# File 'lib/alchemrest/faraday_middleware/kill_switch.rb', line 6 def service_name @service_name end |
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/alchemrest/faraday_middleware/kill_switch.rb', line 13 def call(env) kill_switch = Alchemrest::KillSwitch.new(service_name:) raise KillSwitchEnabledError if kill_switch.active? app.call(env) end |