aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuc Donnet2017-12-21 13:46:16 +0100
committerGitHub2017-12-21 13:46:16 +0100
commitdc520dd4dc445f979507f0aecc5f6b4a095be963 (patch)
treecdce16a174303b9af5cb8abe4007932d87a36ac0
parent38ba7259702dccc5e2ee225e33a0c5390b2ad418 (diff)
parent4dfd620b92d6c9c30401d8ef085e5f39af64742b (diff)
downloadchouette-core-dc520dd4dc445f979507f0aecc5f6b4a095be963.tar.bz2
Merge pull request #162 from af83/5334-add-nulldb-support
5334 Add support fort NullDB in Apartment
-rw-r--r--Gemfile1
-rw-r--r--Gemfile.lock5
-rw-r--r--config/initializers/apartment_null_db.rb25
3 files changed, 30 insertions, 1 deletions
diff --git a/Gemfile b/Gemfile
index 21f534c8b..898293ac5 100644
--- a/Gemfile
+++ b/Gemfile
@@ -65,6 +65,7 @@ end
gem 'activerecord-postgis-adapter', "~> 3.0.0"
gem 'polylines'
+gem 'activerecord-nulldb-adapter', require: false
# Codifligne API
gem 'codifligne', af83: 'stif-codifline-api'
diff --git a/Gemfile.lock b/Gemfile.lock
index f9682dff1..27d3c18eb 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -75,6 +75,8 @@ GEM
activemodel (= 4.2.8)
activesupport (= 4.2.8)
arel (~> 6.0)
+ activerecord-nulldb-adapter (0.3.7)
+ activerecord (>= 2.0.0)
activerecord-postgis-adapter (3.0.0)
activerecord (~> 4.2)
rgeo-activerecord (~> 4.0)
@@ -566,6 +568,7 @@ DEPENDENCIES
SyslogLogger
aasm
active_attr
+ activerecord-nulldb-adapter
activerecord-postgis-adapter (~> 3.0.0)
acts-as-taggable-on (~> 4.0.0)
acts_as_list (~> 0.6.0)
@@ -683,4 +686,4 @@ DEPENDENCIES
will_paginate-bootstrap
BUNDLED WITH
- 1.15.4
+ 1.16.0
diff --git a/config/initializers/apartment_null_db.rb b/config/initializers/apartment_null_db.rb
new file mode 100644
index 000000000..438f1e58b
--- /dev/null
+++ b/config/initializers/apartment_null_db.rb
@@ -0,0 +1,25 @@
+if ENV['RAILS_DB_ADAPTER'] == 'nulldb'
+ require 'apartment/adapters/abstract_adapter'
+
+ module Apartment
+ module Tenant
+ def adapter
+ Thread.current[:apartment_adapter] ||= nulldb_adapter(config)
+ end
+
+ def self.nulldb_adapter(config)
+ adapter = Adapters::NulldbAdapter
+ adapter.new(config)
+ end
+ end
+
+ module Adapters
+ # Default adapter when not using Postgresql Schemas
+ class NulldbAdapter < AbstractAdapter
+ def initialize config
+ super
+ end
+ end
+ end
+ end
+end