app/models/map/extensions/point.rb
# convert any possible object to mongoid native type
convert any possible object to mongoid native type
convert any possible object to mongoid native type
def mongoize(object)
      case object
      when self
        object.mongoize
      when Hash
        h = object.deep_stringify_keys
        return self.new.mongoize if h["loc"].blank?
        h["loc"] = Map::Extensions::Loc.mongoize(h["loc"])
        if h["zoom_level"].present?
          h["zoom_level"] = Integer(h["zoom_level"]) rescue nil
        end
        ret = self.new
        ret.merge!(h)
        ret.mongoize
      else object
      end
    end
def mongoize ( object ) case object when self object . mongoize when Hash h = object . deep_stringify_keys return self . new . mongoize if h [ "loc" ] . blank? h [ "loc" ] = Map :: Extensions :: Loc . mongoize ( h [ "loc" ] ) if h [ "zoom_level" ] . present? h [ "zoom_level" ] = Integer ( h [ "zoom_level" ] ) rescue nil end ret = self . new ret . merge! ( h ) ret . mongoize else object end end
convert any possible object to mongoid native type
convert any possible object to mongoid native type
object
<not_specific>