public
Description: Rails Spatial Adapter plugin
Homepage:
Clone URL: git://github.com/fragility/spatial_adapter.git
spatial_adapter / init.rb
100644 29 lines (22 sloc) 0.85 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class SpatialAdapterNotCompatibleError < StandardError
end
 
 
case ActiveRecord::Base.configurations[RAILS_ENV]['adapter']
when 'mysql'
  require 'mysql_spatial_adapter'
when 'postgresql'
  require 'post_gis_adapter'
else
  raise SpatialAdapterNotCompatibleError.new("Only MySQL and PostgreSQL are currently supported by the spatial adapter plugin.")
end
 
=begin
# when testing RAILS_ENV isn't set so you'll need to use this style of getting the adapter name
# [TODO] come back and make sure RAILS_ENV exists when running the plugin tests
case ActiveRecord::Base.connection.adapter_name
when 'MySQL'
require 'mysql_spatial_adapter'
when 'PostgreSQL'
require 'post_gis_adapter'
else
raise SpatialAdapterNotCompatibleError.new("Only MySQL and PostgreSQL are currently supported by the spatial adapter plugin.")
end
=end