aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZog2017-12-20 08:52:57 +0100
committerZog2017-12-20 09:02:57 +0100
commit477f98b1508796a53870e00a192ff47875c5907c (patch)
treec7ac8bf6116810953ad067fbbfbc2b78193e339e
parente7bece2f871d51ad71ee2ee258afd985bf8d8485 (diff)
downloadchouette-core-477f98b1508796a53870e00a192ff47875c5907c.tar.bz2
Refs #5334@3h; Add support fort NullDB in Apartment
This will allow us to compile assets with a null_db adapter.
-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..1cd5f818c 100644
--- a/Gemfile
+++ b/Gemfile
@@ -65,6 +65,7 @@ end
gem 'activerecord-postgis-adapter', "~> 3.0.0"
gem 'polylines'
+gem 'activerecord-nulldb-adapter'
# 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..b50ec3ad9
--- /dev/null
+++ b/config/initializers/apartment_null_db.rb
@@ -0,0 +1,25 @@
+require 'apartment/adapters/abstract_adapter'
+
+module Apartment
+ module Tenant
+ def adapter
+ Thread.current[:apartment_adapter] ||= begin
+ nulldb_adapter(config)
+ end
+ 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