Sha256: 40938cadcd2a07bdbba21e2953e2c6853d5d003faaec75fbbfe21cbbcb079aa0

Contents?: true

Size: 508 Bytes

Versions: 2

Compression:

Stored size: 508 Bytes

Contents

module RockConfig
  class Config
    def initialize(hash)
      @hash = hash
    end

    def [](key)
      fetch(key)
    end

    def method_missing(name, *args, &block)
      fetch(name.to_s)
    end

    def raw
      @hash.dup
    end

    private

    def fetch(key, default = nil)
      value = @hash[key.to_s]
      value_or_config(value) unless value.nil?
    end

    def value_or_config(value)
      if Hash === value
        Config.new(value)
      else
        value
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rock_config-0.0.7 lib/rock_config/config.rb
rock_config-0.0.6 lib/rock_config/config.rb