Class: MongoidEmbedFinder::Projectors::Base
- Inherits:
-
Struct
- Object
- Struct
- MongoidEmbedFinder::Projectors::Base
- Defined in:
- lib/mongoid_embed_finder/projectors/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#query ⇒ Object
Returns the value of attribute query.
-
#relation ⇒ Object
Returns the value of attribute relation.
Instance Method Summary collapse
Instance Attribute Details
#query ⇒ Object
Returns the value of attribute query
3 4 5 |
# File 'lib/mongoid_embed_finder/projectors/base.rb', line 3 def query @query end |
#relation ⇒ Object
Returns the value of attribute relation
3 4 5 |
# File 'lib/mongoid_embed_finder/projectors/base.rb', line 3 def relation @relation end |
Instance Method Details
#operator ⇒ Object
14 15 16 |
# File 'lib/mongoid_embed_finder/projectors/base.rb', line 14 def operator raise NotImplementedError, "operator needs to be overriden" end |
#project(fields = []) ⇒ Object
8 9 10 11 12 |
# File 'lib/mongoid_embed_finder/projectors/base.rb', line 8 def project(fields = []) projection_with_fields = projection.merge(include_fields(fields)) query.scope_parent(projection) query.execute.select(projection_with_fields) end |
#projection ⇒ Object
4 5 6 |
# File 'lib/mongoid_embed_finder/projectors/base.rb', line 4 def projection { relation.key => { operator => query.child_criteria.selector }} end |