Sha256: b6130fcf884732ecf102df32ba8aa2469c1471bbb1caa56ab2dc4625574c1ea6

Contents?: true

Size: 383 Bytes

Versions: 1

Compression:

Stored size: 383 Bytes

Contents

#require 'ostruct'

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.class_eval do
    (self.spatial_fields ||= []) << field.name.to_sym

    define_method "distance_from_#{field.name}" do |*args|
      self.distance_from(field.name, *args)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongoid_geospatial-2.2.0 lib/mongoid_geospatial/field_option.rb