class Anyway::Rails::Loaders::Secrets

Public Instance Methods

call(name:, **_options) click to toggle source
# File lib/anyway/rails/loaders/secrets.rb, line 9
def call(name:, **_options)
  return {} unless ::Rails.application.respond_to?(:secrets)

  # Create a new hash cause secrets are mutable!
  config = {}

  trace!(:secrets) do
    secrets.public_send(name)
  end.then do |secrets|
    Utils.deep_merge!(config, secrets) if secrets
  end

  config
end

Private Instance Methods

secrets() click to toggle source
# File lib/anyway/rails/loaders/secrets.rb, line 26
def secrets
  @secrets ||= ::Rails.application.secrets.tap do |_|
    # Reset secrets state if the app hasn't been initialized
    # See https://github.com/palkan/anyway_config/issues/14
    next if ::Rails.application.initialized?
    ::Rails.application.remove_instance_variable(:@secrets)
  end
end