Class: Geospatial::Map::Index

Inherits:
Object
  • Object
show all
Defined in:
lib/geospatial/map/index.rb

Overview

Uses dependency injection to generate a class to ‘load` and `dump` a serialized column.

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.mapObject

Returns the value of attribute map.



28
29
30
# File 'lib/geospatial/map/index.rb', line 28

def map
  @map
end

Class Method Details

.dump(point) ⇒ Object



36
37
38
39
40
41
42
43
44
# File 'lib/geospatial/map/index.rb', line 36

def dump(point)
	if point.is_a?(Point)
		point.hash
	elsif point.respond_to?(:to_a)
		map.hash_for_coordinates(point.to_a)
	elsif !point.nil?
		raise ArgumentError.new("Could not convert #{point} on #{map}!")
	end
end

.load(hash) ⇒ Object



30
31
32
33
34
# File 'lib/geospatial/map/index.rb', line 30

def load(hash)
	if hash
		map.point_for_hash(hash)
	end
end