Class: KY::Template
- Inherits:
-
Object
- Object
- KY::Template
- Defined in:
- lib/ky/template.rb
Instance Method Summary collapse
- #context(context_hash) ⇒ Object
- #define_methods_from_config(config) ⇒ Object
-
#initialize(configuration) ⇒ Template
constructor
A new instance of Template.
Constructor Details
#initialize(configuration) ⇒ Template
4 5 6 |
# File 'lib/ky/template.rb', line 4 def initialize(configuration) define_methods_from_config(configuration) end |
Instance Method Details
#context(context_hash) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/ky/template.rb', line 14 def context(context_hash) template_context = binding context_hash.each do |var, value| template_context.local_variable_set(var, value) end template_context end |
#define_methods_from_config(config) ⇒ Object
8 9 10 11 12 |
# File 'lib/ky/template.rb', line 8 def define_methods_from_config(config) config.keys.each do |key| define_singleton_method(key) { config[key] } end end |