Sha256: e365860ee272213fdf2535fcd73274e3206e054568c830d5da1e230553e0acf1

Contents?: true

Size: 819 Bytes

Versions: 5

Compression:

Stored size: 819 Bytes

Contents

# frozen_string_literal: true

module Anyway
  class Config # :nodoc:
    class << self
      def defaults
        return unless @defaults

        @defaults_wia ||= @defaults.with_indifferent_access
      end
    end

    def load_from_sources(config = {})
      config = config.with_indifferent_access
      load_from_file(config)
      load_from_secrets(config)
      load_from_env(config)
    end

    def load_from_file(config)
      config_path = Rails.root.join("config", "#{@config_name}.yml")
      config.deep_merge!(parse_yml(config_path)[Rails.env] || {}) if File.file? config_path
      config
    end

    def load_from_secrets(config)
      if Rails.application.respond_to?(:secrets)
        config.deep_merge!(Rails.application.secrets.send(@config_name) || {})
      end
      config
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
anyway_config-1.4.3 lib/anyway/rails/config.rb
anyway_config-1.4.2 lib/anyway/rails/config.rb
anyway_config-1.4.1 lib/anyway/rails/config.rb
anyway_config-1.4.0 lib/anyway/rails/config.rb
anyway_config-1.3.1 lib/anyway/rails/config.rb