Class: Creds
- Inherits:
-
Object
- Object
- Creds
- Defined in:
- lib/creds.rb,
lib/creds/version.rb
Defined Under Namespace
Classes: PlainConfiguration, Railtie
Constant Summary collapse
- VERSION =
"1.0.1"
Instance Method Summary collapse
- #[](key) ⇒ Object
- #configuration ⇒ Object
-
#initialize(file_path, key_path: "config/master.key", env_key: "RAILS_MASTER_KEY", raise_if_missing_key: true, env: nil) ⇒ Creds
constructor
A new instance of Creds.
Constructor Details
#initialize(file_path, key_path: "config/master.key", env_key: "RAILS_MASTER_KEY", raise_if_missing_key: true, env: nil) ⇒ Creds
Returns a new instance of Creds.
12 13 14 15 16 17 18 |
# 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 |
Instance Method Details
#[](key) ⇒ Object
20 21 22 |
# File 'lib/creds.rb', line 20 def [](key) configuration[key.to_sym] end |
#configuration ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# 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 |