Class: Nanoc::ConfigView

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

Direct Known Subclasses

MutableConfigView

Constant Summary collapse

NONE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Object.new.freeze

Instance Method Summary collapse

Methods inherited from View

#_context, #frozen?, #inspect

Constructor Details

#initialize(config, context) ⇒ ConfigView

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ConfigView.



7
8
9
10
# File 'lib/nanoc/base/views/config_view.rb', line 7

def initialize(config, context)
  super(context)
  @config = config
end

Instance Method Details

#[](key) ⇒ Object

See Also:

  • Hash#[]


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

def [](key)
  @config[key]
end

#each(&block) ⇒ Object

See Also:

  • Hash#each


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

def each(&block)
  @config.each(&block)
end

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

See Also:

  • Hash#fetch


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

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

#key?(key) ⇒ Boolean

Returns:

  • (Boolean)

See Also:

  • Hash#key?


31
32
33
# File 'lib/nanoc/base/views/config_view.rb', line 31

def key?(key)
  @config.key?(key)
end

#unwrapObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



13
14
15
# File 'lib/nanoc/base/views/config_view.rb', line 13

def unwrap
  @config
end