Module: Mongoid::Extensions::Symbol::Inflections

Defined in:
lib/mongoid/geo/inflections.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#geoNearObject

$nearSphere $centerSphere

nearMax

  • { $near : [50,50] , $maxDistance : 5 }

withinBox

  • : {“$box” : box

withinCenter

  • : {“$center” : [center, radius]}})



15
16
17
# File 'lib/mongoid/geo/inflections.rb', line 15

def geoNear
  Criterion::Complex.new(:operator => 'geoNearSphere', :key => self)
end

#nearMax(*calcs) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/mongoid/geo/inflections.rb', line 23

def nearMax *calcs
  calcs = (!calcs || calcs.empty?) ? [:flat] : calcs
  case calcs.size
  when 1
    Criterion::TwinOperators.new(:op_a => get_op(calcs.first, 'near'), :op_b => get_op(calcs.first, 'maxDistance'), :key => self)
  when 2
    Criterion::TwinOperators.new(:op_a => get_op(calcs.first, 'near'), :op_b => get_op(calcs.last, 'maxDistance'), :key => self)            
  else
    raise "method nearMax takes one or two symbols as arguments, each symbol must be either :flat or :sphere"
  end
end

#nearSphereObject



19
20
21
# File 'lib/mongoid/geo/inflections.rb', line 19

def nearSphere
  Criterion::Complex.new(:operator => 'nearSphere', :key => self)          
end

#withinBox(calc = :flat) ⇒ Object



35
36
37
# File 'lib/mongoid/geo/inflections.rb', line 35

def withinBox calc = :flat
  Criterion::OuterOperator.new(:outer_op => 'within', :operator => get_op(calc, 'box'), :key => self)
end

#withinCenter(calc = :flat) ⇒ Object



39
40
41
# File 'lib/mongoid/geo/inflections.rb', line 39

def withinCenter calc = :flat
  Criterion::OuterOperator.new(:outer_op => 'within', :operator => get_op(calc, 'center'), :key => self)
end