forked from pdeffendol/spatial_adapter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.rb
27 lines (23 loc) · 909 Bytes
/
init.rb
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
class SpatialAdapterNotCompatibleError < StandardError
end
if defined? RAILS_ENV
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
else
# 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