class Creds

Constants

VERSION

Public Class Methods

new(file_path, key_path: "config/master.key", env_key: "RAILS_MASTER_KEY", raise_if_missing_key: true, env: nil) click to toggle source
# File lib/creds.rb, line 12
def initialize(file_path, key_path: "config/master.key", env_key: "RAILS_MASTER_KEY", raise_if_missing_key: true, env: nil)
  @file_path            = file_path
  @key_path             = key_path
  @env_key              = env_key
  @raise_if_missing_key = raise_if_missing_key
  @env                  = env
end

Public Instance Methods

[](key) click to toggle source
# File lib/creds.rb, line 20
def [](key)
  configuration[key.to_sym]
end
configuration() click to toggle source
# File lib/creds.rb, line 24
def configuration
  @configuration ||= if @file_path.end_with?(".enc")
    ActiveSupport::EncryptedConfiguration.new(
      config_path: @file_path,
      key_path: @key_path,
      env_key: @env_key,
      raise_if_missing_key: @raise_if_missing_key
    )
  else
    Creds::PlainConfiguration.new(@file_path, env: @env)
  end
end