Class: OpenWeatherClient::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/open_weather_client-caching-redis/configuration.rb

Overview

Configuratin of OpenWeatherClient

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

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

#dbObject

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

#hostObject

String

host of the redis server



12
13
14
# File 'lib/open_weather_client-caching-redis/configuration.rb', line 12

def host
  @host
end

#passwordObject

Integer

password of the redis server



14
15
16
# File 'lib/open_weather_client-caching-redis/configuration.rb', line 14

def password
  @password
end

#portObject

Integer

port of the redis server



16
17
18
# File 'lib/open_weather_client-caching-redis/configuration.rb', line 16

def port
  @port
end

#ttlObject

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_credentialsObject

Raises:

  • (KeyError)


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_initializeObject



20
# File 'lib/open_weather_client-caching-redis/configuration.rb', line 20

alias old_initialize initialize

#old_loadObject



31
# File 'lib/open_weather_client-caching-redis/configuration.rb', line 31

alias old_load load_from_rails_credentials