app/models/map/extensions/loc.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 String
        object = object.gsub(/[, 　、\r\n]+/, ",").split(",").select(&:present?)
        self[Float(object[0]), Float(object[1])].mongoize rescue []
      when Array
        self[Float(object[0]), Float(object[1])].mongoize rescue []
      when Hash
        lat = object[:lat].presence || object['lat']
        lng = object[:lng].presence || object['lng']
        self[Float(lat), Float(lng)].mongoize rescue []
      else
        object
      end
    end
def mongoize ( object ) case object when self object . mongoize when String object = object . gsub ( / [, 　、\r\n ]+ /,  " , " .sp l i t("," ) .se l e ct(&:p r e sent?) self [ Float ( object [ 0 ] ) , Float ( object [ 1 ] ) ] . mongoize rescue [ ] when Array self [ Float ( object [ 0 ] ) , Float ( object [ 1 ] ) ] . mongoize rescue [ ] when Hash lat = object [ :lat ] . presence || object [ 'lat' ] lng = object [ :lng ] . presence || object [ 'lng' ] self [ Float ( lat ) , Float ( lng ) ] . mongoize rescue [ ] else object end end
convert any possible object to mongoid native type
convert any possible object to mongoid native type
# unknown type
object
<not_specific>