Class: Anyway::Rails::Loaders::Credentials
- Inherits:
-
Loaders::Base
- Object
- Loaders::Base
- Anyway::Rails::Loaders::Credentials
- Defined in:
- lib/anyway/rails/loaders/credentials.rb
Constant Summary collapse
- LOCAL_CONTENT_PATH =
"config/credentials/local.yml.enc"
Instance Method Summary collapse
Methods inherited from Loaders::Base
call, #initialize, #use_local?
Methods included from Tracing
capture, current_trace, current_trace_source, source_stack, trace!, trace_stack, with_trace_source
Constructor Details
This class inherits a constructor from Anyway::Loaders::Base
Instance Method Details
#call(name:, **_options) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/anyway/rails/loaders/credentials.rb', line 11 def call(name:, **) return {} unless ::Rails.application.respond_to?(:credentials) # do not load from credentials if we're in the context # of the `credentials:edit` command return {} if defined?(::Rails::Command::CredentialsCommand) # Create a new hash cause credentials are mutable! config = {} trace!( :credentials, store: credentials_path ) do ::Rails.application.credentials.config[name.to_sym] end.then do |creds| Utils.deep_merge!(config, creds) if creds end if use_local? trace!(:credentials, store: LOCAL_CONTENT_PATH) do local_credentials(name) end.then { |creds| Utils.deep_merge!(config, creds) if creds } end config end |