Sha256: 0894384a11d161446194a163afb7bdab750690ac3a2068ccffd94c19adc84cc2

Contents?: true

Size: 648 Bytes

Versions: 1

Compression:

Stored size: 648 Bytes

Contents

module Nanoc
  class ConfigView
    # @api private
    NONE = Object.new

    # @api private
    def initialize(config)
      @config = config
    end

    # @api private
    def unwrap
      @config
    end

    # @see Hash#fetch
    def fetch(key, fallback=NONE, &block)
      @config.fetch(key) do
        if !fallback.equal?(NONE)
          fallback
        elsif block_given?
          yield(key)
        else
          raise KeyError, "key not found: #{key.inspect}"
        end
      end
    end

    # @see Hash#key?
    def key?(key)
      @config.key?(key)
    end

    # @see Hash#[]
    def [](key)
      @config[key]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nanoc-4.0.0b3 lib/nanoc/base/views/config.rb