Class: SnippetTemplateDefinition
- Inherits:
-
Object
- Object
- SnippetTemplateDefinition
- Defined in:
- lib/ccios/snippet_template_definition.rb
Instance Method Summary collapse
- #generate(context, template_definition) ⇒ Object
-
#initialize(snippet_template_definition_hash) ⇒ SnippetTemplateDefinition
constructor
A new instance of SnippetTemplateDefinition.
- #validate(template_definition) ⇒ Object
Constructor Details
#initialize(snippet_template_definition_hash) ⇒ SnippetTemplateDefinition
Returns a new instance of SnippetTemplateDefinition.
4 5 6 7 |
# File 'lib/ccios/snippet_template_definition.rb', line 4 def initialize(snippet_template_definition_hash) @name = snippet_template_definition_hash["name"] @template = snippet_template_definition_hash["template"] end |
Instance Method Details
#generate(context, template_definition) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/ccios/snippet_template_definition.rb', line 18 def generate(context, template_definition) file_creator = FileCreator.new file_creator.print_file_content_using_template( @name, template_definition.template_source_file(@template), context ) end |
#validate(template_definition) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/ccios/snippet_template_definition.rb', line 9 def validate(template_definition) expected_context_keys = template_definition.provided_context_keys file_creator = FileCreator.new contentTags = file_creator.(template_definition.template_source_file(@template)) contentTags.each do |tag| raise "Unknown parameter \"#{tag}\" in template \"#{@template}\"" unless expected_context_keys.include?(tag) end end |