Class: HSQL::Template
- Inherits:
-
Object
- Object
- HSQL::Template
- Defined in:
- lib/hsql/template.rb
Overview
Given some SQL that may contain Mustache tags (e.g. variable }} ), accept a hash of data that interpolates each tag. Throws an error if one of the tag names can’t be found in the data.
Instance Attribute Summary collapse
-
#input ⇒ Object
readonly
Returns the value of attribute input.
Instance Method Summary collapse
-
#initialize(input) ⇒ Template
constructor
A new instance of Template.
- #render(hash) ⇒ Object
- #variable_names ⇒ Object
Constructor Details
#initialize(input) ⇒ Template
Returns a new instance of Template.
9 10 11 |
# File 'lib/hsql/template.rb', line 9 def initialize(input) @input = input end |
Instance Attribute Details
#input ⇒ Object (readonly)
Returns the value of attribute input.
7 8 9 |
# File 'lib/hsql/template.rb', line 7 def input @input end |
Instance Method Details
#render(hash) ⇒ Object
17 18 19 |
# File 'lib/hsql/template.rb', line 17 def render(hash) Mustache.render(input, hash) end |
#variable_names ⇒ Object
13 14 15 |
# File 'lib/hsql/template.rb', line 13 def variable_names extract_variable_names(ast).uniq end |