Sha256: 89c17ca8e1e8c6285e3cb1b7db13b65ff46a7b2e070211eca7f5588b4ac89c7c
Contents?: true
Size: 1.06 KB
Versions: 12
Compression:
Stored size: 1.06 KB
Contents
# frozen_string_literal: true module Nanoc class ConfigView < ::Nanoc::View # @api private NONE = Object.new.freeze # @api private def initialize(config, context) super(context) @config = config end # @api private def unwrap @config end # @see Hash#fetch def fetch(key, fallback = NONE, &_block) @context.dependency_tracker.bounce(unwrap, attributes: [key]) @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) @context.dependency_tracker.bounce(unwrap, attributes: [key]) @config.key?(key) end # @see Hash#[] def [](key) @context.dependency_tracker.bounce(unwrap, attributes: [key]) @config[key] end # @see Hash#each def each(&block) @context.dependency_tracker.bounce(unwrap, attributes: true) @config.each(&block) end end end
Version data entries
12 entries across 12 versions & 1 rubygems