Class: Querylet::Template
- Inherits:
-
Object
- Object
- Querylet::Template
- Defined in:
- lib/querylet/template.rb
Instance Method Summary collapse
-
#call(args = nil) ⇒ Object
In Ruby, the call method is used to invoke a block, proc, or lambda, which are all different types of callable objects in Ruby.
-
#initialize(querylet, ast) ⇒ Template
constructor
A new instance of Template.
Constructor Details
#initialize(querylet, ast) ⇒ Template
Returns a new instance of Template.
5 6 7 8 |
# File 'lib/querylet/template.rb', line 5 def initialize(querylet, ast) @querylet = querylet @ast = ast end |
Instance Method Details
#call(args = nil) ⇒ Object
In Ruby, the call method is used to invoke a block, proc, or lambda, which are all different types of callable objects in Ruby.
This is how querylet will get called in a developers code.
querylet = Querylet::Querylet.new path: ‘path/to/sql’ querylet.compile(template).call(data)
18 19 20 21 22 23 |
# File 'lib/querylet/template.rb', line 18 def call(args = nil) ctx = Context.new(@querylet, args) # AST should return a Querylet::Tree and call its eval method @ast.eval(ctx) end |