Class: Querylet::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/querylet/template.rb

Instance Method Summary collapse

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



10
11
12
13
14
15
16
17
# File 'lib/querylet/template.rb', line 10

def call(args = nil)
  if args
    @querylet.set_context(args)
  end

  # AST should return a Querylet::Tree and call its eval method
  @ast.eval(@querylet)
end