Class: OpenWeatherClient::Configuration
- Inherits:
-
Object
- Object
- OpenWeatherClient::Configuration
- Defined in:
- lib/open_weather_client-caching-redis/configuration.rb
Overview
Configuratin of OpenWeatherClient
Instance Attribute Summary collapse
-
#db ⇒ Object
- Integer
-
db of the redis server used for caching.
-
#host ⇒ Object
- String
-
host of the redis server.
-
#password ⇒ Object
- Integer
-
password of the redis server.
-
#port ⇒ Object
- Integer
-
port of the redis server.
-
#ttl ⇒ Object
- Integer
-
The time in days until an entry cached in redis is expired.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #load_from_rails_credentials ⇒ Object
- #old_initialize ⇒ Object
- #old_load ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
22 23 24 25 26 27 28 29 |
# File 'lib/open_weather_client-caching-redis/configuration.rb', line 22 def initialize old_initialize self.db = 0 self.host = 'localhost' self.port = 6379 self.ttl = 7 end |
Instance Attribute Details
#db ⇒ Object
- Integer
-
db of the redis server used for caching
10 11 12 |
# File 'lib/open_weather_client-caching-redis/configuration.rb', line 10 def db @db end |
#host ⇒ Object
- String
-
host of the redis server
12 13 14 |
# File 'lib/open_weather_client-caching-redis/configuration.rb', line 12 def host @host end |
#password ⇒ Object
- Integer
-
password of the redis server
14 15 16 |
# File 'lib/open_weather_client-caching-redis/configuration.rb', line 14 def password @password end |
#port ⇒ Object
- Integer
-
port of the redis server
16 17 18 |
# File 'lib/open_weather_client-caching-redis/configuration.rb', line 16 def port @port end |
#ttl ⇒ Object
- Integer
-
The time in days until an entry cached in redis is expired
18 19 20 |
# File 'lib/open_weather_client-caching-redis/configuration.rb', line 18 def ttl @ttl end |
Instance Method Details
#load_from_rails_credentials ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/open_weather_client-caching-redis/configuration.rb', line 33 def load_from_rails_credentials old_load settings = Rails.application.credentials.open_weather_client![:redis] raise KeyError unless settings self.host = settings[:host] self.port = settings[:port] self.db = settings[:db] self.password = settings[:password] end |
#old_initialize ⇒ Object
20 |
# File 'lib/open_weather_client-caching-redis/configuration.rb', line 20 alias old_initialize initialize |
#old_load ⇒ Object
31 |
# File 'lib/open_weather_client-caching-redis/configuration.rb', line 31 alias old_load load_from_rails_credentials |