Class: Castle::Configuration
- Inherits:
-
Object
- Object
- Castle::Configuration
- Defined in:
- lib/castle/configuration.rb
Overview
manages configuration variables
Constant Summary collapse
- 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' ].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.
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/castle/configuration.rb', line 27 def initialize @formatter = Castle::HeaderFormatter.new @request_timeout = REQUEST_TIMEOUT self.failover_strategy = :allow self.host = 'api.castle.io' self.port = 443 self.url_prefix = 'v1' 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(m, *_args) ⇒ Object (private)
67 68 69 |
# File 'lib/castle/configuration.rb', line 67 def method_missing(m, *_args) raise Castle::ConfigurationError, "there is no such a config #{m}" end |
Instance Attribute Details
#api_secret ⇒ Object
Returns the value of attribute api_secret.
25 26 27 |
# File 'lib/castle/configuration.rb', line 25 def api_secret @api_secret end |
#blacklisted ⇒ Object
Returns the value of attribute blacklisted.
25 26 27 |
# File 'lib/castle/configuration.rb', line 25 def blacklisted @blacklisted end |
#failover_strategy ⇒ Object
Returns the value of attribute failover_strategy.
25 26 27 |
# File 'lib/castle/configuration.rb', line 25 def failover_strategy @failover_strategy end |
#host ⇒ Object
Returns the value of attribute host.
24 25 26 |
# File 'lib/castle/configuration.rb', line 24 def host @host end |
#port ⇒ Object
Returns the value of attribute port.
24 25 26 |
# File 'lib/castle/configuration.rb', line 24 def port @port end |
#request_timeout ⇒ Object
Returns the value of attribute request_timeout.
24 25 26 |
# File 'lib/castle/configuration.rb', line 24 def request_timeout @request_timeout end |
#url_prefix ⇒ Object
Returns the value of attribute url_prefix.
24 25 26 |
# File 'lib/castle/configuration.rb', line 24 def url_prefix @url_prefix end |
#whitelisted ⇒ Object
Returns the value of attribute whitelisted.
25 26 27 |
# File 'lib/castle/configuration.rb', line 25 def whitelisted @whitelisted end |
Instance Method Details
#valid? ⇒ Boolean
51 52 53 |
# File 'lib/castle/configuration.rb', line 51 def valid? !api_secret.to_s.empty? && !host.to_s.empty? && !port.to_s.empty? end |