Module: Ekylibre::Secret

Defined in:
lib/ekylibre/secret.rb

Constant Summary collapse

@@secret_file =
Rails.root.join('config', 'api.yml')

Class Method Summary collapse

Class Method Details

.envObject


11
12
13
# File 'lib/ekylibre/secret.rb', line 11

def self.env
  @@env ||= Rails.env.to_sym
end

.find!(name) ⇒ Object


15
16
17
18
19
20
21
22
23
24
# File 'lib/ekylibre/secret.rb', line 15

def self.find!(name)
  if store[name].is_a?(String)
    return store[name]
  elsif store[name].is_a?(Hash)
    return store[name][env]
  elsif store[env].is_a?(Hash)
    return store[env][name.to_s]
  end
  nil
end

.storeObject


7
8
9
# File 'lib/ekylibre/secret.rb', line 7

def self.store
  @@store ||= (secret_file.exist? ? YAML.load_file(secret_file) : {}).deep_symbolize_keys
end