lib/mongoid_geospatial/fields/point.rb in mongoid_geospatial-2.3.0 vs lib/mongoid_geospatial/fields/point.rb in mongoid_geospatial-2.5.0

- old
+ new

@@ -1,8 +1,9 @@ module Mongoid module Geospatial class Point + include Enumerable attr_accessor :x, :y def initialize(x=nil, y=nil) @x, @y = x, y end @@ -16,10 +17,15 @@ def [](args) mongoize[args] end + def each + yield x + yield y + end + def to_hsh xl = :x, yl = :y {xl => x, yl => y} end alias :to_hash :to_hsh @@ -56,10 +62,10 @@ class << self # Database -> Object def demongoize(object) - # return unless object && !object.empty? + return unless object Point.new(*object) end def mongoize(object) case object