Class: Nanoc::ConfigView

Inherits:
View
  • Object
show all
Defined in:
lib/nanoc/base/views/config_view.rb

Direct Known Subclasses

MutableConfigView

Instance Method Summary collapse

Methods inherited from View

#frozen?, #inspect

Instance Method Details

#[](key) ⇒ Object

See Also:

  • Hash#[]


40
41
42
43
# File 'lib/nanoc/base/views/config_view.rb', line 40

def [](key)
  @context.dependency_tracker.bounce(unwrap, attributes: [key])
  @config[key]
end

#dig(*keys) ⇒ Object

See Also:

  • Hash#dig


52
53
54
55
# File 'lib/nanoc/base/views/config_view.rb', line 52

def dig(*keys)
  @context.dependency_tracker.bounce(unwrap, attributes: keys.take(1))
  @config.dig(*keys)
end

#each(&block) ⇒ Object

See Also:

  • Hash#each


46
47
48
49
# File 'lib/nanoc/base/views/config_view.rb', line 46

def each(&block)
  @context.dependency_tracker.bounce(unwrap, attributes: true)
  @config.each(&block)
end

#fetch(key, fallback = NONE, &_block) ⇒ Object

See Also:

  • Hash#fetch


20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/nanoc/base/views/config_view.rb', line 20

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

#key?(key) ⇒ Boolean

Returns:

  • (Boolean)

See Also:

  • Hash#key?


34
35
36
37
# File 'lib/nanoc/base/views/config_view.rb', line 34

def key?(key)
  @context.dependency_tracker.bounce(unwrap, attributes: [key])
  @config.key?(key)
end