Class: Alchemrest::Client::Configuration
- Inherits:
-
Object
- Object
- Alchemrest::Client::Configuration
- Defined in:
- lib/alchemrest/client/configuration.rb,
lib/alchemrest/client/configuration/connection.rb
Defined Under Namespace
Classes: Connection
Instance Attribute Summary collapse
-
#circuit_breaker ⇒ Object
readonly
Returns the value of attribute circuit_breaker.
-
#kill_switch_enabled ⇒ Object
readonly
Returns the value of attribute kill_switch_enabled.
-
#service_name ⇒ Object
Returns the value of attribute service_name.
-
#underscore_response_body_keys ⇒ Object
Returns the value of attribute underscore_response_body_keys.
Instance Method Summary collapse
- #connection ⇒ Object
- #freeze ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #kill_switch_enabled? ⇒ Boolean
- #ready? ⇒ Boolean
- #use_circuit_breaker(circuit_breaker_option = nil) ⇒ Object
-
#use_kill_switch(value = true) ⇒ Object
rubocop:disable Style/OptionalBooleanParameter.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
14 15 16 |
# File 'lib/alchemrest/client/configuration.rb', line 14 def initialize @underscore_response_body_keys = true end |
Instance Attribute Details
#circuit_breaker ⇒ Object (readonly)
Returns the value of attribute circuit_breaker.
9 10 11 |
# File 'lib/alchemrest/client/configuration.rb', line 9 def circuit_breaker @circuit_breaker end |
#kill_switch_enabled ⇒ Object (readonly)
Returns the value of attribute kill_switch_enabled.
9 10 11 |
# File 'lib/alchemrest/client/configuration.rb', line 9 def kill_switch_enabled @kill_switch_enabled end |
#service_name ⇒ Object
Returns the value of attribute service_name.
6 7 8 |
# File 'lib/alchemrest/client/configuration.rb', line 6 def service_name @service_name end |
#underscore_response_body_keys ⇒ Object
Returns the value of attribute underscore_response_body_keys.
6 7 8 |
# File 'lib/alchemrest/client/configuration.rb', line 6 def underscore_response_body_keys @underscore_response_body_keys end |
Instance Method Details
#connection ⇒ Object
18 19 20 |
# File 'lib/alchemrest/client/configuration.rb', line 18 def connection @connection ||= Connection.new(self) end |
#freeze ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/alchemrest/client/configuration.rb', line 22 def freeze connection.freeze # enable defaults if they haven't been explicitly configured unless circuit_breaker use_circuit_breaker end if kill_switch_enabled.nil? use_kill_switch end super() end |
#kill_switch_enabled? ⇒ Boolean
12 |
# File 'lib/alchemrest/client/configuration.rb', line 12 def kill_switch_enabled? = kill_switch_enabled |
#ready? ⇒ Boolean
37 38 39 |
# File 'lib/alchemrest/client/configuration.rb', line 37 def ready? frozen? end |
#use_circuit_breaker(circuit_breaker_option = nil) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/alchemrest/client/configuration.rb', line 41 def use_circuit_breaker(circuit_breaker_option = nil) ensure_service_name! raise InvalidConfigurationError, "already called `use_circuit_breaker`" unless circuit_breaker.nil? @circuit_breaker = case circuit_breaker_option in CircuitBreaker circuit_breaker_option in Hash => build_default_circuit_breaker(**) in true | nil build_default_circuit_breaker in false build_default_circuit_breaker(disabled_when: -> { true }) end end |
#use_kill_switch(value = true) ⇒ Object
rubocop:disable Style/OptionalBooleanParameter
57 58 59 60 61 62 |
# File 'lib/alchemrest/client/configuration.rb', line 57 def use_kill_switch(value = true) # rubocop:disable Style/OptionalBooleanParameter ensure_service_name! raise InvalidConfigurationError, "already called `use_kill_switch`" unless kill_switch_enabled.nil? @kill_switch_enabled = value end |