Class: MongoQL::Stage::Lookup::NestedPipelineVars
- Inherits:
-
Object
- Object
- MongoQL::Stage::Lookup::NestedPipelineVars
- Defined in:
- lib/mongo_ql/stage/lookup.rb
Instance Attribute Summary collapse
-
#vars ⇒ Object
Returns the value of attribute vars.
Instance Method Summary collapse
- #get(name) ⇒ Object
-
#initialize ⇒ NestedPipelineVars
constructor
A new instance of NestedPipelineVars.
- #method_missing(m, *args, &block) ⇒ Object
- #set(name, val) ⇒ Object
Constructor Details
#initialize ⇒ NestedPipelineVars
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
#vars ⇒ Object
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 |