Class: Mongoid::Location::Polygon
- Inherits:
-
Object
- Object
- Mongoid::Location::Polygon
- Includes:
- Fields::Serializable
- Defined in:
- lib/mongoid_location/fields/polygon.rb,
lib/mongoid_location/fields/mongoid2/polygon.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.demongoize(object) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/mongoid_location/fields/polygon.rb', line 11 def demongoize(object) points = object.map do |pair| RGeo::Geographic.spherical_factory.point *pair end ring = RGeo::Geographic.spherical_factory.linear_ring points RGeo::Geographic.spherical_factory.polygon ring end |
.instantiate(name, options = {}) ⇒ Object
6 7 8 |
# File 'lib/mongoid_location/fields/mongoid2/polygon.rb', line 6 def self.instantiate name, = {} super end |
Instance Method Details
#deserialize(object) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/mongoid_location/fields/mongoid2/polygon.rb', line 14 def deserialize(object) points = object.map do |pair| RGeo::Geographic.spherical_factory.point *pair end ring = RGeo::Geographic.spherical_factory.linear_ring points RGeo::Geographic.spherical_factory.polygon ring end |
#mongoize ⇒ Object
6 7 8 |
# File 'lib/mongoid_location/fields/polygon.rb', line 6 def mongoize self #.flatten end |
#serialize(object) ⇒ Object
10 11 12 |
# File 'lib/mongoid_location/fields/mongoid2/polygon.rb', line 10 def serialize(object) object end |