class RailsEnvCredentials::Config

Attributes

env[R]

Public Class Methods

new(env: nil, config_path: nil) click to toggle source
# File lib/rails_env_credentials/config.rb, line 7
def initialize(env: nil, config_path: nil)
  @env = env.nil? ? Rails.env : ActiveSupport::StringInquirer.new(env)
  @config_path = config_path
end

Public Instance Methods

to_options() click to toggle source
# File lib/rails_env_credentials/config.rb, line 12
def to_options
  env_key = env_suffix("RAILS_MASTER_KEY", "_").upcase
  key_path = "config/#{env_suffix("master")}.key"

  {
    config_path: config_path,
    env_key: env_key,
    key_path: key_path,
    raise_if_missing_key: false
  }
end

Private Instance Methods

config_path() click to toggle source
# File lib/rails_env_credentials/config.rb, line 26
def config_path
  @config_path || "config/#{env_suffix("credentials")}.yml.enc"
end
env_suffix(str, suffix = "-") click to toggle source
# File lib/rails_env_credentials/config.rb, line 30
def env_suffix(str, suffix = "-")
  env.production? ? str : [str, suffix, env].join
end