Class: DataMapper::Property::ParseGeoPoint
- Inherits:
-
Object
- Object
- DataMapper::Property::ParseGeoPoint
- Defined in:
- lib/property/parse_geo_point.rb
Instance Method Summary collapse
Instance Method Details
#dump(value) ⇒ Object
6 7 8 |
# File 'lib/property/parse_geo_point.rb', line 6 def dump(value) value && value.merge("__type" => "GeoPoint") end |
#load(value) ⇒ Object
10 11 12 |
# File 'lib/property/parse_geo_point.rb', line 10 def load(value) value end |
#typecast(value) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/property/parse_geo_point.rb', line 14 def typecast(value) case value when ::Hash lat = value["latitude"] lng = value["longitude"] { "latitude" => lat.to_f, "longitude" => lng.to_f } if lat.present? && lng.present? end end |
#valid?(value) ⇒ Boolean
23 24 25 26 |
# File 'lib/property/parse_geo_point.rb', line 23 def valid?(value) return false if value && (value["latitude"].blank? || value["longitude"].blank?) super end |