Sha256: 17a8b034cd5820d7236764086e6d6e7957e4cbf7f168162dd6adc684240c156b
Contents?: true
Size: 1.52 KB
Versions: 5
Compression:
Stored size: 1.52 KB
Contents
# frozen_string_literal: true module NCMB module Query [ {greaterThan: '$gt'}, {notEqualTo: '$ne'}, {equalTo: nil}, {lessThan: '$lt'}, {lessThanOrEqualTo: '$lte'}, {greaterThanOrEqualTo: '$gte'}, {in: '$in'}, {notIn: '$nin'}, {exists: '$exists'}, {regex: '$regex'}, {inArray: '$inArray'}, {notInArray: '$ninArray'}, {allInArray: '$all'}, ].each do |m| define_method m.keys.first do |name, value| params = {} if m.values.first.nil? params[name] = value else params[name] = {} params[name][m.values.first] = value end @queries[@search_key] << params self end end [ {withinKilometers: '$maxDistanceInKilometers'}, {withinMiles: '$maxDistanceInMiles'}, {withinRadians: '$maxDistanceInRadians'} ].each do |m| define_method m.keys.first do |name, geo, value| params = {} params[name] = { '$nearSphere': geo, } params[name][m.values.first] = value @queries[@search_key] << params self end end def withinSquare(name, geo1, geo2) params = {} params[name] = { '$within': { '$box': [ geo1, geo2 ] } } @queries[@search_key] << params self end def where(name, value) params = {} params[name] = value @queries[@search_key] << params self end end end
Version data entries
5 entries across 5 versions & 1 rubygems