Class: Nanoc::Core::ConfigView
- Inherits:
-
View
- Object
- View
- Nanoc::Core::ConfigView
show all
- Defined in:
- lib/nanoc/core/config_view.rb
Instance Method Summary
collapse
Methods inherited from View
#_context, #frozen?, #inspect
enabled?, included, setup_once, warn_about_performance
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/core/config_view.rb', line 7
def initialize(config, context)
super(context)
@config = config
end
|
Instance Method Details
#[](key) ⇒ Object
43
44
45
46
|
# File 'lib/nanoc/core/config_view.rb', line 43
def [](key)
@context.dependency_tracker.bounce(_unwrap, attributes: [key])
@config[key]
end
|
#_unwrap ⇒ Object
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/core/config_view.rb', line 13
def _unwrap
@config
end
|
#dig(*keys) ⇒ Object
61
62
63
64
|
# File 'lib/nanoc/core/config_view.rb', line 61
def dig(*keys)
@context.dependency_tracker.bounce(_unwrap, attributes: keys.take(1))
@config.dig(*keys)
end
|
#each ⇒ Object
49
50
51
52
|
# File 'lib/nanoc/core/config_view.rb', line 49
def each(&)
@context.dependency_tracker.bounce(_unwrap, attributes: true)
@config.each(&)
end
|
#env_name ⇒ Object
55
56
57
58
|
# File 'lib/nanoc/core/config_view.rb', line 55
def env_name
@context.dependency_tracker.bounce(_unwrap, attributes: true)
@config.env_name
end
|
#fetch(key, fallback = Nanoc::Core::UNDEFINED) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/nanoc/core/config_view.rb', line 23
def fetch(key, fallback = Nanoc::Core::UNDEFINED, &)
@context.dependency_tracker.bounce(_unwrap, attributes: [key])
@config.fetch(key) do
if !Nanoc::Core::UNDEFINED.equal?(fallback)
fallback
elsif block_given?
yield(key)
else
raise KeyError, "key not found: #{key.inspect}"
end
end
end
|
#key?(key) ⇒ Boolean
37
38
39
40
|
# File 'lib/nanoc/core/config_view.rb', line 37
def key?(key)
@context.dependency_tracker.bounce(_unwrap, attributes: [key])
@config.key?(key)
end
|
#output_dir ⇒ Object
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.
18
19
20
|
# File 'lib/nanoc/core/config_view.rb', line 18
def output_dir
@config.output_dir
end
|