Class: Praxis::Mapper::Support::MemoryQuery
- Inherits:
-
Query::Base
- Object
- Query::Base
- Praxis::Mapper::Support::MemoryQuery
- Defined in:
- lib/praxis-mapper/support/memory_query.rb
Constant Summary
Constants inherited from Query::Base
Query::Base::MULTI_GET_BATCH_SIZE
Instance Attribute Summary
Attributes inherited from Query::Base
#contexts, #identity_map, #model, #statistics, #where
Instance Method Summary collapse
- #_execute ⇒ Object
- #_multi_get(key, values) ⇒ Object
- #collection ⇒ Object
-
#describe ⇒ Object
Subclasses Must Implement.
Methods inherited from Query::Base
#apply_selector, #connection, #context, #default_select, #execute, #initialize, #limit, #load, #multi_get, #select, #to_records, #track, #tracked_associations
Constructor Details
This class inherits a constructor from Praxis::Mapper::Query::Base
Instance Method Details
#_execute ⇒ Object
23 24 25 |
# File 'lib/praxis-mapper/support/memory_query.rb', line 23 def _execute connection.all(model.table_name, self.where||{}).to_a end |
#_multi_get(key, values) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/praxis-mapper/support/memory_query.rb', line 11 def _multi_get(key, values) results = values.collect do |value| connection.all(model, key => value) end.flatten.uniq results.select do |result| where.nil? || where.all? do |k,v| result[k] == v end end end |
#collection ⇒ Object
7 8 9 |
# File 'lib/praxis-mapper/support/memory_query.rb', line 7 def collection connection.collection(model.table_name) end |
#describe ⇒ Object
Subclasses Must Implement
28 29 30 |
# File 'lib/praxis-mapper/support/memory_query.rb', line 28 def describe raise "subclass responsibility" end |