Class: MongoQL::Expression::FieldNode

Inherits:
MongoQL::Expression show all
Defined in:
lib/mongo_ql/expression/field_node.rb

Constant Summary

Constants inherited from MongoQL::Expression

FORMATING_OPS

Constants included from CollectionOperators

CollectionOperators::AGGREGATE_OPS

Constants included from UnaryOperators

UnaryOperators::UNARY_OPS

Constants included from BinaryOperators

BinaryOperators::BINARY_OPS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from MongoQL::Expression

#as_date, #if_null, #then, #type

Methods included from StringOperators

#concat, #substr, #trim

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_nameObject

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

#ascObject



31
32
33
# File 'lib/mongo_ql/expression/field_node.rb', line 31

def asc
  Expression::Ascend.new(self)
end

#dscObject



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_astObject



19
20
21
# File 'lib/mongo_ql/expression/field_node.rb', line 19

def to_ast
  "$#{field_name}"
end

#to_sObject



23
24
25
# File 'lib/mongo_ql/expression/field_node.rb', line 23

def to_s
  field_name.to_s
end