module MongoQL

Constants

EXPRESSION_TO_AST_MAPPER
VERSION

Public Class Methods

compose(*variable_names, &block) click to toggle source
# File lib/mongo_ql.rb, line 19
def self.compose(*variable_names, &block)
  block_binding = block.binding
  ctx = MongoQL::StageContext.new

  variables = variable_names.map do |name|
    [name, block_binding.local_variable_get(name)]
  end.to_h

  # Update injected local variables to ValueNode expressions
  variable_names.each do |name|
    ctx.injected_vars[name] = Expression::ValueNode.new(variables[name])
    block_binding.local_variable_set(name, ctx.injected_vars[name])
  end

  ctx.instance_exec(*variables, &block)
  ctx
ensure
  # Restore local variables
  variable_names.each do |name|
    block_binding.local_variable_set(name, variables[name])
  end
end
logger() click to toggle source
# File lib/mongo_ql.rb, line 42
def self.logger
  @logger ||= Logger.new($stdout)
end