Class: Castle::Configuration
- Inherits:
-
Object
- Object
- Castle::Configuration
- Defined in:
- lib/castle/configuration.rb
Overview
manages configuration variables
Constant Summary collapse
- HOST =
'api.castle.io'- PORT =
443- URL_PREFIX =
'v1'- FAILOVER_STRATEGY =
:allow- REQUEST_TIMEOUT =
in milliseconds
500- FAILOVER_STRATEGIES =
%i[allow deny challenge throw].freeze
- WHITELISTED =
[ 'User-Agent', 'Accept-Language', 'Accept-Encoding', 'Accept-Charset', 'Accept', 'Accept-Datetime', 'X-Forwarded-For', 'Forwarded', 'X-Forwarded', 'X-Real-IP', 'REMOTE_ADDR', 'X-Forwarded-For', 'CF_CONNECTING_IP' ].freeze
- BLACKLISTED =
['HTTP_COOKIE'].freeze
Instance Attribute Summary collapse
-
#api_secret ⇒ Object
Returns the value of attribute api_secret.
-
#blacklisted ⇒ Object
Returns the value of attribute blacklisted.
-
#failover_strategy ⇒ Object
Returns the value of attribute failover_strategy.
-
#host ⇒ Object
Returns the value of attribute host.
-
#port ⇒ Object
Returns the value of attribute port.
-
#request_timeout ⇒ Object
Returns the value of attribute request_timeout.
-
#url_prefix ⇒ Object
Returns the value of attribute url_prefix.
-
#whitelisted ⇒ Object
Returns the value of attribute whitelisted.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #valid? ⇒ Boolean
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/castle/configuration.rb', line 32 def initialize @formatter = Castle::HeaderFormatter.new @request_timeout = REQUEST_TIMEOUT self.failover_strategy = FAILOVER_STRATEGY self.host = HOST self.port = PORT self.url_prefix = URL_PREFIX self.whitelisted = WHITELISTED self.blacklisted = BLACKLISTED self.api_secret = '' end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(setting, *_args) ⇒ Object (private)
71 72 73 |
# File 'lib/castle/configuration.rb', line 71 def method_missing(setting, *_args) raise Castle::ConfigurationError, "there is no such a config #{setting}" end |
Instance Attribute Details
#api_secret ⇒ Object
Returns the value of attribute api_secret.
30 31 32 |
# File 'lib/castle/configuration.rb', line 30 def api_secret @api_secret end |
#blacklisted ⇒ Object
Returns the value of attribute blacklisted.
30 31 32 |
# File 'lib/castle/configuration.rb', line 30 def blacklisted @blacklisted end |
#failover_strategy ⇒ Object
Returns the value of attribute failover_strategy.
30 31 32 |
# File 'lib/castle/configuration.rb', line 30 def failover_strategy @failover_strategy end |
#host ⇒ Object
Returns the value of attribute host.
29 30 31 |
# File 'lib/castle/configuration.rb', line 29 def host @host end |
#port ⇒ Object
Returns the value of attribute port.
29 30 31 |
# File 'lib/castle/configuration.rb', line 29 def port @port end |
#request_timeout ⇒ Object
Returns the value of attribute request_timeout.
29 30 31 |
# File 'lib/castle/configuration.rb', line 29 def request_timeout @request_timeout end |
#url_prefix ⇒ Object
Returns the value of attribute url_prefix.
29 30 31 |
# File 'lib/castle/configuration.rb', line 29 def url_prefix @url_prefix end |
#whitelisted ⇒ Object
Returns the value of attribute whitelisted.
30 31 32 |
# File 'lib/castle/configuration.rb', line 30 def whitelisted @whitelisted end |
Instance Method Details
#valid? ⇒ Boolean
56 57 58 |
# File 'lib/castle/configuration.rb', line 56 def valid? !api_secret.to_s.empty? && !host.to_s.empty? && !port.to_s.empty? end |