Class: RGeo::ActiveRecord::SpatialFactoryStore

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

Defined Under Namespace

Classes: Entry

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSpatialFactoryStore

Returns a new instance of SpatialFactoryStore.



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

def initialize
  @registry = []
  @default = nil
end

Instance Attribute Details

#registryObject

Returns the value of attribute registry.



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

def registry
  @registry
end

Instance Method Details

#clearObject



32
33
34
# File 'lib/rgeo/active_record/spatial_factory_store.rb', line 32

def clear
  @registry = []
end

#default(attrs = {}) ⇒ Object



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

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

#default=(factory) ⇒ Object



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

def default=(factory)
  @default = factory
end

#factory(attrs) ⇒ Object



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

def factory(attrs)
  closest_factory(attrs) || default(attrs)
end

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



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

def register(factory, attrs = {})
  registry.push(Entry.new(filter_attrs(attrs), factory))
end