Module: Templator::DslMethods
- Defined in:
- lib/templator/parameter_dsl.rb
Overview
Module that defines the Parameter DSL methods.
Constant Summary collapse
- TOP_LEVEL_GROUP_NAME =
Name of the implicit top level group
"__top__"
Instance Method Summary collapse
-
#export(params) ⇒ Object
Defines parameters providing a name and a value for each parameter.
-
#group(name) { ... } ⇒ Object
Defines a group of parameters.
-
#include_group(group) ⇒ Object
Includes all parameters and sub groups of a given group into the current group.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object (private)
Manages the access to a parameter outside of the current group
231 232 233 |
# File 'lib/templator/parameter_dsl.rb', line 231 def method_missing(name, *args) DslContext.top_level_group.send(name, *args) end |
Instance Method Details
#export(params) ⇒ Object
Defines parameters providing a name and a value for each parameter.
165 166 167 168 169 |
# File 'lib/templator/parameter_dsl.rb', line 165 def export(params) params.each do |name, value| define_method_in_current_group(name) {value} end end |
#group(name) { ... } ⇒ Object
Defines a group of parameters.
174 175 176 177 178 |
# File 'lib/templator/parameter_dsl.rb', line 174 def group(name) enter_group name.to_s yield leave_group end |
#include_group(group) ⇒ Object
Includes all parameters and sub groups of a given group into the current group.
182 183 184 185 186 187 188 189 190 |
# File 'lib/templator/parameter_dsl.rb', line 182 def include_group(group) source_group = group if ! group.kind_of? Group source_group = get_group group.to_s end source_group.singleton_methods.each do |method| define_method_in_current_group(method) {source_group.send(method)} end end |