Sha256: 9584137a7900004e83678124685607db87117042624c6b6ec637afd49b6bcc3c

Contents?: true

Size: 617 Bytes

Versions: 5

Compression:

Stored size: 617 Bytes

Contents

Mongoid::Fields.option :spatial do |model,field,options|
  options = {} unless options.kind_of?(Hash)
  # x_meth = options[:x] || :x
  # y_meth = options[:y] || :y

  # model.instance_eval do # wont work
  # #   define_method "near_#{field.name}" do |*args|
  # #     self.where(field.name => args)
  # #   end
  # end

  model.class_eval do
    self.spatial_fields << field.name.to_sym
    self.spatial_fields_indexed << field.name.to_sym

    # Create 2D index
    spatial_index field.name

    # define_method "near_#{field.name}" do |*args|
    #   queryable.where(field.near_sphere => args)
    # end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mongoid_geospatial-2.8.2 lib/mongoid_geospatial/helpers/spatial.rb
mongoid_geospatial-2.8.1 lib/mongoid_geospatial/helpers/spatial.rb
mongoid_geospatial-2.8.0 lib/mongoid_geospatial/helpers/spatial.rb
mongoid_geospatial-2.7.2 lib/mongoid_geospatial/helpers/spatial.rb
mongoid_geospatial-2.7.1 lib/mongoid_geospatial/helpers/spatial.rb