Module: Mongoid::Extensions::Symbol

Defined in:
lib/mongoid_location/extensions/symbol.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#near(calc = :flat) ⇒ Criterion::NearSpatial

return a class that will accept a value to convert the query correctly for near

Parameters:

  • calc (Symbol) (defaults to: :flat)

    This accepts :sphere

Returns:



12
13
14
# File 'lib/mongoid_location/extensions/symbol.rb', line 12

def near(calc = :flat)
  Criterion::NearSpatial.new(:operator => get_op('near',calc), :key => self)
end

#near_sphereCriterion::NearSpatial

alias for self.near(:sphere)



19
20
21
# File 'lib/mongoid_location/extensions/symbol.rb', line 19

def near_sphere
  self.near(:sphere)
end

#within(shape) ⇒ Criterion::WithinSpatial

Parameters:

  • shape (Symbol)

    :box,:polygon,:center,:center_sphere

Returns:



26
27
28
29
# File 'lib/mongoid_location/extensions/symbol.rb', line 26

def within(shape)
  shape = get_op(:center,:sphere) if shape == :center_sphere
  Criterion::WithinSpatial.new(:operator => shape.to_s , :key => self)
end