Sha256: 7b7e793b2967de466cb6ec1f2c67815389702a0a4d79977338f184c2266d9466

Contents?: true

Size: 512 Bytes

Versions: 2

Compression:

Stored size: 512 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)
      if value = @hash[key.to_s]
        return value_or_config(value)
      end
    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.5 lib/rock_config/config.rb
rock_config-0.0.4 lib/rock_config/config.rb