Class: MongoQL::Stage::Lookup::NestedPipelineVars

Inherits:
Object
  • Object
show all
Defined in:
lib/mongo_ql/stage/lookup.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeNestedPipelineVars

Returns a new instance of NestedPipelineVars.



8
9
10
# File 'lib/mongo_ql/stage/lookup.rb', line 8

def initialize
  @vars = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/mongo_ql/stage/lookup.rb', line 12

def method_missing(m, *args, &block)
  if is_setter?(m)
    set(m, args.first)
  else
    get(m)
  end
end

Instance Attribute Details

#varsObject

Returns the value of attribute vars.



6
7
8
# File 'lib/mongo_ql/stage/lookup.rb', line 6

def vars
  @vars
end

Instance Method Details

#get(name) ⇒ Object



20
21
22
23
# File 'lib/mongo_ql/stage/lookup.rb', line 20

def get(name)
  vars["var_#{name}"] ||= Expression::FieldNode.new(name)
  Expression::FieldNode.new("$var_#{name}")
end

#set(name, val) ⇒ Object



25
26
27
# File 'lib/mongo_ql/stage/lookup.rb', line 25

def set(name, val)
  vars["var_#{name.to_s[0..-2]}"] = val
end