class Querylet::Querylet

Public Class Methods

new(path:) click to toggle source
# File lib/querylet.rb, line 10
def initialize(path:)
  @sql_path = path
end

Public Instance Methods

compile(content) click to toggle source
# File lib/querylet.rb, line 14
def compile(content)
  parser    = Parser.new
  transform = Transform.new
  #puts "parser.parse"
  deep_nested_hash = parser.parse_with_debug(content)
  #puts deep_nested_hash
  abstract_syntax_tree = transform.apply deep_nested_hash
  #puts abstract_syntax_tree
  Template.new self, abstract_syntax_tree
end
get_partial(name, dot_path) click to toggle source
# File lib/querylet.rb, line 29
def get_partial name, dot_path
  path = @sql_path + '/' + dot_path.to_s.split('.').join('/') + '.sql'
  template = File.read(path).to_s.chomp
  self.compile(template).call(@data)
end
set_context(ctx) click to toggle source
# File lib/querylet.rb, line 25
def set_context(ctx)
  @data = ctx
end