Sha256: 7323d909b45e1f8eaf3d837aa9cac8c1994493568aec5f05ce10fd568a43024c

Contents?: true

Size: 810 Bytes

Versions: 9

Compression:

Stored size: 810 Bytes

Contents

# frozen_string_literal: true

module Anyway
  # Adds ability to generate anonymous (class-less) config dynamicly
  # (like Rails.application.config_for but using more data sources).
  module DynamicConfig
    module ClassMethods
      # Load config as Hash by any name
      #
      # Example:
      #
      #   my_config = Anyway::Config.for(:my_app)
      #   # will load data from config/my_app.yml, secrets.my_app, ENV["MY_APP_*"]
      #
      def for(name, **options)
        config = allocate
        options[:env_prefix] ||= name.to_s.upcase
        options[:config_path] ||= config.resolve_config_path(name, options[:env_prefix])
        config.load_from_sources(new_empty_config, name: name, **options)
      end
    end

    def self.included(base)
      base.extend ClassMethods
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
anyway_config-2.1.0 lib/.rbnext/1995.next/anyway/dynamic_config.rb
anyway_config-2.0.6 lib/anyway/dynamic_config.rb
anyway_config-2.0.5 lib/anyway/dynamic_config.rb
anyway_config-2.0.4 lib/anyway/dynamic_config.rb
anyway_config-2.0.3 lib/anyway/dynamic_config.rb
anyway_config-2.0.2 lib/anyway/dynamic_config.rb
anyway_config-2.0.1 lib/anyway/dynamic_config.rb
anyway_config-2.0.0 lib/anyway/dynamic_config.rb
anyway_config-2.0.0.rc1 lib/anyway/dynamic_config.rb