Class: RailsEnvCredentials::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_env_credentials/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env: nil, config_path: nil) ⇒ Config

Returns a new instance of Config.



7
8
9
10
# 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

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



5
6
7
# File 'lib/rails_env_credentials/config.rb', line 5

def env
  @env
end

Instance Method Details

#to_optionsObject



12
13
14
15
16
17
18
19
20
21
22
# 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