Sha256: a3f7fc4f9f4db769465662dbdeb5452248401dccfe72c591a601e10c6271714b

Contents?: true

Size: 1.02 KB

Versions: 51

Compression:

Stored size: 1.02 KB

Contents

require 'rubypitaya/core/config_core'

module RubyPitaya

  class Config

    def initialize
      @config_core = ConfigCore.new
      @config_core_override = nil
      @has_config_core_override = false

      @empty_hash = {}
      @result_cache = {}
    end

    def [](key)
      result = @result_cache[key]
      return result unless result.nil?

      if @has_config_core_override
        result = @config_core_override[key]
        result = @config_core[key] if result.nil?
      else
        result = @config_core[key]
      end

      @result_cache[key] = result

      result
    end

    def fetch(*args)
      result = self[args[0]]
      return result unless result.nil?

      @empty_hash.fetch(*args)
    end

    def auto_reload
      @config_core.auto_reload
      @config_core_override.auto_reload unless @config_core_override.nil?
    end

    def clear_cache
      @result_cache.clear
    end

    def config_core_override=(value)
      @config_core_override = value
      @has_config_core_override = !value.nil?
    end
  end
end

Version data entries

51 entries across 47 versions & 1 rubygems

Version Path
rubypitaya-3.14.0 ./lib/rubypitaya/core/config.rb
rubypitaya-3.13.1 ./lib/rubypitaya/core/config.rb
rubypitaya-3.13.0 ./lib/rubypitaya/core/config.rb
rubypitaya-3.12.5 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rubypitaya-3.12.1/lib/rubypitaya/core/config.rb
rubypitaya-3.12.5 ./lib/rubypitaya/core/config.rb
rubypitaya-3.12.4 ./lib/rubypitaya/core/config.rb
rubypitaya-3.12.4 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rubypitaya-3.12.1/lib/rubypitaya/core/config.rb
rubypitaya-3.12.3 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rubypitaya-3.12.1/lib/rubypitaya/core/config.rb
rubypitaya-3.12.3 ./lib/rubypitaya/core/config.rb
rubypitaya-3.12.2 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rubypitaya-3.12.1/lib/rubypitaya/core/config.rb
rubypitaya-3.12.2 ./lib/rubypitaya/core/config.rb
rubypitaya-3.12.1 ./lib/rubypitaya/core/config.rb
rubypitaya-3.12.0 ./lib/rubypitaya/core/config.rb
rubypitaya-3.11.0 ./lib/rubypitaya/core/config.rb
rubypitaya-3.10.0 ./lib/rubypitaya/core/config.rb
rubypitaya-3.9.1 ./lib/rubypitaya/core/config.rb
rubypitaya-3.8.1 ./lib/rubypitaya/core/config.rb
rubypitaya-3.8.0 ./lib/rubypitaya/core/config.rb
rubypitaya-3.7.0 ./lib/rubypitaya/core/config.rb
rubypitaya-3.6.0 ./lib/rubypitaya/core/config.rb