Sha256: 95d326360194fa4bfdc97d9689ab464a3c2354d6bf6cf14181c83035e6cc6ee7

Contents?: true

Size: 771 Bytes

Versions: 4

Compression:

Stored size: 771 Bytes

Contents

# frozen_string_literal: true

module Anyway
  module Rails
    module Loaders
      class YAML < Anyway::Loaders::YAML
        def load_base_yml(*)
          parsed_yml = super
          return parsed_yml unless environmental?(parsed_yml)

          super[::Rails.env] || {}
        end

        private

        def environmental?(parsed_yml)
          return true unless Settings.future.unwrap_known_environments
          # likely
          return true if parsed_yml.key?(::Rails.env)
          # less likely
          ::Rails.application.config.anyway_config.known_environments.any? { |_1| parsed_yml.key?(_1) }
        end

        def relative_config_path(path)
          Pathname.new(path).relative_path_from(::Rails.root)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
anyway_config-2.2.2 lib/.rbnext/2.7/anyway/rails/loaders/yaml.rb
anyway_config-2.2.1 lib/.rbnext/2.7/anyway/rails/loaders/yaml.rb
anyway_config-2.2.0 lib/.rbnext/2.7/anyway/rails/loaders/yaml.rb
anyway_config-2.1.0 lib/.rbnext/2.7/anyway/rails/loaders/yaml.rb