Class: SecureCredentials::Credentials

Inherits:
Object
  • Object
show all
Defined in:
lib/secure_credentials/credentials.rb

Overview

Wraps store into compatible with Rails::Application#credentials interface.

Instance Method Summary collapse

Constructor Details

#initialize(store) ⇒ Credentials

Returns a new instance of Credentials.



13
14
15
# File 'lib/secure_credentials/credentials.rb', line 13

def initialize(store)
  @store = store
end

Instance Method Details

#dataObject



27
28
29
# File 'lib/secure_credentials/credentials.rb', line 27

def data
  @data ||= ActiveSupport::OrderedOptions.new.merge(store.content.deep_symbolize_keys)
end

#keyObject

Required by ‘rails encrypted` command.



21
22
23
24
25
# File 'lib/secure_credentials/credentials.rb', line 21

def key
  store.send(:encrypted_file).key if store.encrypted?
rescue ActiveSupport::EncryptedFile::MissingKeyError
  nil
end