Class: RGeo::ActiveRecord::SpatialFactoryStore

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/rgeo/active_record/spatial_factory_store.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSpatialFactoryStore

Returns a new instance of SpatialFactoryStore


8
9
10
# File 'lib/rgeo/active_record/spatial_factory_store.rb', line 8

def initialize
  @registry = {}
end

Instance Attribute Details

#registryObject

Returns the value of attribute registry


6
7
8
# File 'lib/rgeo/active_record/spatial_factory_store.rb', line 6

def registry
  @registry
end

Instance Method Details

#clearObject


28
29
30
# File 'lib/rgeo/active_record/spatial_factory_store.rb', line 28

def clear
  @registry = {}
end

#default(attrs = {}) ⇒ Object


16
17
18
# File 'lib/rgeo/active_record/spatial_factory_store.rb', line 16

def default(attrs = {})
  @default || default_for_attrs(attrs)
end

#default=(factory) ⇒ Object


20
21
22
# File 'lib/rgeo/active_record/spatial_factory_store.rb', line 20

def default=(factory)
  @default = factory
end

#factory(attrs) ⇒ Object


24
25
26
# File 'lib/rgeo/active_record/spatial_factory_store.rb', line 24

def factory(attrs)
  registry[key(attrs)] || default(attrs)
end

#register(factory, attrs = {}) ⇒ Object


12
13
14
# File 'lib/rgeo/active_record/spatial_factory_store.rb', line 12

def register(factory, attrs = {})
  registry[key(attrs)] = factory
end