Sha256: ba771de6b01126d474abfae632c9201c4758dc5e3bcce9064e6214c94f37d60c

Contents?: true

Size: 818 Bytes

Versions: 3

Compression:

Stored size: 818 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

3 entries across 3 versions & 1 rubygems

Version Path
anyway_config-1.3.0 lib/anyway/rails/config.rb
anyway_config-1.2.0 lib/anyway/rails/config.rb
anyway_config-1.1.3 lib/anyway/rails/config.rb