Class: Volt::DataStore::MongoAdaptorClient
- Inherits:
-
BaseAdaptorClient
- Object
- BaseAdaptorClient
- Volt::DataStore::MongoAdaptorClient
- Defined in:
- app/mongo/lib/mongo_adaptor_client.rb
Defined Under Namespace
Modules: MongoArrayStore
Class Method Summary collapse
- .merge_finds_and_move_to_front(query) ⇒ Object
- .normalize_query(query) ⇒ Object
- .reject_skip_zero(query) ⇒ Object
Class Method Details
.merge_finds_and_move_to_front(query) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/mongo/lib/mongo_adaptor_client.rb', line 40 def self.merge_finds_and_move_to_front(query) # Map first parts to string query = query.map { |v| v[0] = v[0].to_s; v } has_find = query.find { |v| v[0] == 'find' } if has_find # merge any finds merged_find_query = {} query = query.reject do |query_part| if query_part[0] == 'find' # on a find, merge into finds find_query = query_part[1] merged_find_query.merge!(find_query) if find_query # reject true else false end end # Add finds to the front query.insert(0, ['find', merged_find_query]) else # No find was done, add it in the first position query.insert(0, ['find']) end query end |
.normalize_query(query) ⇒ Object
32 33 34 35 36 37 38 |
# File 'app/mongo/lib/mongo_adaptor_client.rb', line 32 def self.normalize_query(query) query = merge_finds_and_move_to_front(query) query = reject_skip_zero(query) query end |
.reject_skip_zero(query) ⇒ Object
71 72 73 74 75 |
# File 'app/mongo/lib/mongo_adaptor_client.rb', line 71 def self.reject_skip_zero(query) query.reject do |query_part| query_part[0] == 'skip' && query_part[1] == 0 end end |