Class: MongoQL::Expression::MethodCall

Inherits:
MongoQL::Expression show all
Defined in:
lib/mongo_ql/expression/method_call.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(method, target, ast_template: nil, **args) ⇒ MethodCall

Returns a new instance of MethodCall.



7
8
9
10
11
12
# File 'lib/mongo_ql/expression/method_call.rb', line 7

def initialize(method, target, ast_template: nil, **args)
  @method       = method
  @args         = args
  @target       = to_expression(target)
  @ast_template = ast_template
end

Instance Attribute Details

#argsObject

Returns the value of attribute args.



5
6
7
# File 'lib/mongo_ql/expression/method_call.rb', line 5

def args
  @args
end

#ast_templateObject

Returns the value of attribute ast_template.



5
6
7
# File 'lib/mongo_ql/expression/method_call.rb', line 5

def ast_template
  @ast_template
end

#methodObject

Returns the value of attribute method.



5
6
7
# File 'lib/mongo_ql/expression/method_call.rb', line 5

def method
  @method
end

#targetObject

Returns the value of attribute target.



5
6
7
# File 'lib/mongo_ql/expression/method_call.rb', line 5

def target
  @target
end

Instance Method Details

#to_astObject



14
15
16
17
18
19
20
# File 'lib/mongo_ql/expression/method_call.rb', line 14

def to_ast
  if ast_template
    { method => ast_template.call(target, **args) }
  else
    { method => target }
  end
end