Class: Kdep::TemplateContext
- Inherits:
-
Object
- Object
- Kdep::TemplateContext
- Defined in:
- lib/kdep/template_context.rb
Instance Method Summary collapse
- #get_binding ⇒ Object
-
#initialize(config, secrets = {}) ⇒ TemplateContext
constructor
A new instance of TemplateContext.
-
#yaml_value(val) ⇒ Object
Helper: render a value as YAML-safe string.
Constructor Details
#initialize(config, secrets = {}) ⇒ TemplateContext
Returns a new instance of TemplateContext.
3 4 5 6 7 8 9 10 11 |
# File 'lib/kdep/template_context.rb', line 3 def initialize(config, secrets = {}) @config = config @secrets = secrets # Expose top-level config keys as methods for cleaner templates config.each do |key, value| define_singleton_method(key.to_sym) { value } if key.is_a?(String) end end |
Instance Method Details
#get_binding ⇒ Object
13 14 15 |
# File 'lib/kdep/template_context.rb', line 13 def get_binding binding end |
#yaml_value(val) ⇒ Object
Helper: render a value as YAML-safe string
18 19 20 |
# File 'lib/kdep/template_context.rb', line 18 def yaml_value(val) val.is_a?(String) ? val : val.to_s end |