Sha256: 169f0b28e31729f781260651d47933bd1184a0b2dcbf137e8e15f7328a269163

Contents?: true

Size: 908 Bytes

Versions: 3

Compression:

Stored size: 908 Bytes

Contents

module Chambermaid
  class Namespace
    # @param [String] path
    # @param [Boolean] overload
    def initialize(path:, overload: false)
      @path = path
      @overload = overload

      @store = ParameterStore.new(path: path)
      @env = Environment.new({})
    end

    def self.load!(path:, overload: false)
      namespace = new(path: path, overload: overload)
      namespace.load!
      namespace
    end

    def load!
      @store.load!
      load_env!
    end

    def reload!
      @env.unload!
      @store.reload!
      load_env!
    end

    def unload!
      @env.unload!
      Chambermaid.logger.info("unloaded #{@env.size} params from ENV")
    end

    private

    # Inject into ENV
    def load_env!
      @env.replace(@store.params)
      @overload ? @env.overload! : @env.load!
      Chambermaid.logger.info("loaded #{@env.size} params into ENV from `#{@path}`")
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
chambermaid-0.5.4 lib/chambermaid/namespace.rb
chambermaid-0.4.1 lib/chambermaid/namespace.rb
chambermaid-0.4.0 lib/chambermaid/namespace.rb