Class: MongoQL::Expression::FieldNode
- Inherits:
-
MongoQL::Expression
- Object
- MongoQL::Expression
- MongoQL::Expression::FieldNode
- Defined in:
- lib/mongo_ql/expression/field_node.rb
Constant Summary
Constants inherited from MongoQL::Expression
Constants included from CollectionOperators
CollectionOperators::AGGREGATE_OPS
Constants included from UnaryOperators
Constants included from BinaryOperators
Instance Attribute Summary collapse
-
#field_name ⇒ Object
Returns the value of attribute field_name.
Instance Method Summary collapse
- #asc ⇒ Object
- #dsc ⇒ Object
- #f(field) ⇒ Object
-
#initialize(name) ⇒ FieldNode
constructor
A new instance of FieldNode.
- #method_missing(method_name, *args, &block) ⇒ Object
- #to_ast ⇒ Object
- #to_s ⇒ Object
Methods inherited from MongoQL::Expression
#as_date, #if_null, #then, #type
Methods included from StringOperators
Methods included from CollectionOperators
#any?, #concat_arrays, #contains, #filter, #map, #reduce
Constructor Details
#initialize(name) ⇒ FieldNode
Returns a new instance of FieldNode.
7 8 9 |
# File 'lib/mongo_ql/expression/field_node.rb', line 7 def initialize(name) @field_name = name end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
11 12 13 |
# File 'lib/mongo_ql/expression/field_node.rb', line 11 def method_missing(method_name, *args, &block) Expression::FieldNode.new("#{field_name}.#{method_name}") end |
Instance Attribute Details
#field_name ⇒ Object
Returns the value of attribute field_name.
5 6 7 |
# File 'lib/mongo_ql/expression/field_node.rb', line 5 def field_name @field_name end |
Instance Method Details
#asc ⇒ Object
31 32 33 |
# File 'lib/mongo_ql/expression/field_node.rb', line 31 def asc Expression::Ascend.new(self) end |
#dsc ⇒ Object
27 28 29 |
# File 'lib/mongo_ql/expression/field_node.rb', line 27 def dsc Expression::Descend.new(self) end |
#f(field) ⇒ Object
15 16 17 |
# File 'lib/mongo_ql/expression/field_node.rb', line 15 def f(field) Expression::FieldNode.new("#{field_name}.#{field}") end |
#to_ast ⇒ Object
19 20 21 |
# File 'lib/mongo_ql/expression/field_node.rb', line 19 def to_ast "$#{field_name}" end |
#to_s ⇒ Object
23 24 25 |
# File 'lib/mongo_ql/expression/field_node.rb', line 23 def to_s field_name.to_s end |