Class: ConfigTemplates::Contexts::Rendering
- Inherits:
-
Object
- Object
- ConfigTemplates::Contexts::Rendering
show all
- Defined in:
- lib/config_templates/contexts/rendering.rb
Instance Method Summary
collapse
Constructor Details
#initialize(settings, config) ⇒ Rendering
5
6
7
8
|
# File 'lib/config_templates/contexts/rendering.rb', line 5
def initialize(settings, config)
@settings = settings
@config = config
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name) ⇒ Object
20
21
22
23
24
|
# File 'lib/config_templates/contexts/rendering.rb', line 20
def method_missing(method_name)
stage_request = method_name[-1] == '?'
stage = method_name[0..-2] if stage_request
stage.nil? ? super : stage?(stage)
end
|
Instance Method Details
#param(path, default = nil) ⇒ Object
10
11
12
13
14
|
# File 'lib/config_templates/contexts/rendering.rb', line 10
def param(path, default = nil)
path.split('.').inject(@settings.find_all) { |value, current| value[current] }
rescue
default
end
|
#respond_to_missing?(method_name) ⇒ Boolean
26
27
28
|
# File 'lib/config_templates/contexts/rendering.rb', line 26
def respond_to_missing?(method_name)
method_name[-1] == '?' || super
end
|
#stage ⇒ Object
16
17
18
|
# File 'lib/config_templates/contexts/rendering.rb', line 16
def stage
@config.stage
end
|