Class: MongoQL::Stage::Match
- Inherits:
-
MongoQL::Stage
- Object
- MongoQL::Stage
- MongoQL::Stage::Match
- Defined in:
- lib/mongo_ql/stage/match.rb
Instance Attribute Summary collapse
-
#conditions ⇒ Object
Returns the value of attribute conditions.
-
#ctx ⇒ Object
Returns the value of attribute ctx.
-
#field_filters ⇒ Object
Returns the value of attribute field_filters.
Instance Method Summary collapse
-
#initialize(ctx, *conds, **field_filters) ⇒ Match
constructor
A new instance of Match.
- #to_ast ⇒ Object
Constructor Details
#initialize(ctx, *conds, **field_filters) ⇒ Match
Returns a new instance of Match.
7 8 9 10 11 12 13 14 |
# File 'lib/mongo_ql/stage/match.rb', line 7 def initialize(ctx, *conds, **field_filters) @ctx = ctx conds.each do |c| raise ArgumentError, "#{c.inspect} is not a valid MongoQL::Expression" unless c.is_a?(MongoQL::Expression) end @conditions = conds @field_filters = field_filters end |
Instance Attribute Details
#conditions ⇒ Object
Returns the value of attribute conditions.
5 6 7 |
# File 'lib/mongo_ql/stage/match.rb', line 5 def conditions @conditions end |
#ctx ⇒ Object
Returns the value of attribute ctx.
5 6 7 |
# File 'lib/mongo_ql/stage/match.rb', line 5 def ctx @ctx end |
#field_filters ⇒ Object
Returns the value of attribute field_filters.
5 6 7 |
# File 'lib/mongo_ql/stage/match.rb', line 5 def field_filters @field_filters end |
Instance Method Details
#to_ast ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/mongo_ql/stage/match.rb', line 16 def to_ast conds = {} if compose_conditions conds["$expr"] = compose_conditions end ast = { "$match" => conds.merge(field_filters) } MongoQL::Utils.deep_transform_values(ast, &MongoQL::EXPRESSION_TO_AST_MAPPER) end |