apartment 0.22.1 → 0.23.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -2
- data/.rspec +2 -1
- data/.travis.yml +3 -1
- data/Appraisals +7 -0
- data/Gemfile +0 -21
- data/HISTORY.md +6 -0
- data/README.md +13 -71
- data/Rakefile +4 -2
- data/TODO.md +0 -5
- data/apartment.gemspec +19 -0
- data/gemfiles/rails3.2.gemfile +7 -0
- data/gemfiles/rails4.0.gemfile +7 -0
- data/lib/apartment.rb +2 -28
- data/lib/apartment/adapters/abstract_adapter.rb +0 -2
- data/lib/apartment/adapters/abstract_jdbc_adapter.rb +2 -0
- data/lib/apartment/adapters/jdbc_mysql_adapter.rb +2 -0
- data/lib/apartment/adapters/jdbc_postgresql_adapter.rb +1 -1
- data/lib/apartment/adapters/mysql2_adapter.rb +2 -3
- data/lib/apartment/adapters/postgis_adapter.rb +0 -1
- data/lib/apartment/adapters/postgresql_adapter.rb +2 -3
- data/lib/apartment/adapters/sqlite3_adapter.rb +2 -0
- data/lib/apartment/database.rb +0 -4
- data/lib/apartment/elevators/domain.rb +2 -0
- data/lib/apartment/elevators/first_subdomain.rb +2 -0
- data/lib/apartment/elevators/generic.rb +3 -0
- data/lib/apartment/elevators/host_hash.rb +2 -0
- data/lib/apartment/elevators/subdomain.rb +19 -2
- data/lib/apartment/migrator.rb +2 -1
- data/lib/apartment/railtie.rb +2 -2
- data/lib/apartment/reloader.rb +0 -3
- data/lib/apartment/version.rb +2 -2
- data/lib/tasks/apartment.rake +2 -0
- data/spec/adapters/jdbc_mysql_adapter_spec.rb +1 -3
- data/spec/adapters/jdbc_postgresql_adapter_spec.rb +1 -3
- data/spec/adapters/mysql2_adapter_spec.rb +1 -2
- data/spec/adapters/postgresql_adapter_spec.rb +1 -2
- data/spec/adapters/sqlite3_adapter_spec.rb +1 -2
- data/spec/database_spec.rb +32 -50
- data/spec/dummy/app/models/user.rb +0 -2
- data/spec/dummy/config/application.rb +2 -0
- data/spec/dummy/config/environments/development.rb +2 -0
- data/spec/dummy/config/environments/production.rb +2 -0
- data/spec/dummy/config/environments/test.rb +1 -2
- data/spec/dummy/config/initializers/apartment.rb +1 -1
- data/spec/dummy/db/seeds.rb +1 -4
- data/spec/examples/elevator_examples.rb +4 -4
- data/spec/integration/apartment_rake_integration_spec.rb +15 -19
- data/spec/integration/middleware/domain_elevator_spec.rb +4 -3
- data/spec/integration/middleware/generic_elevator_spec.rb +4 -3
- data/spec/integration/middleware/subdomain_elevator_spec.rb +29 -3
- data/spec/integration/query_caching_spec.rb +8 -4
- data/spec/schemas/v1.rb +16 -0
- data/spec/schemas/v2.rb +43 -0
- data/spec/schemas/v3.rb +49 -0
- data/spec/spec_helper.rb +5 -11
- data/spec/support/apartment_helpers.rb +4 -2
- data/spec/support/contexts.rb +15 -19
- data/spec/support/requirements.rb +1 -17
- data/spec/support/setup.rb +47 -0
- data/spec/tasks/apartment_rake_spec.rb +6 -3
- data/spec/unit/config_spec.rb +3 -3
- data/spec/unit/middleware/domain_elevator_spec.rb +1 -2
- data/spec/{integration → unit}/middleware/first_subdomain_elevator_spec.rb +1 -0
- data/spec/unit/middleware/host_hash_elevator_spec.rb +1 -2
- data/spec/unit/middleware/subdomain_elevator_spec.rb +1 -2
- data/spec/unit/migrator_spec.rb +5 -4
- data/spec/unit/reloader_spec.rb +6 -4
- metadata +130 -14
- data/lib/apartment/delayed_job/enqueue.rb +0 -26
- data/lib/apartment/delayed_job/hooks.rb +0 -26
- data/lib/apartment/delayed_job/psych_ext.rb +0 -61
- data/lib/apartment/delayed_job/requirements.rb +0 -23
- data/lib/apartment/delayed_job/syck_ext.rb +0 -29
- data/spec/dummy/lib/fake_dj_class.rb +0 -6
- data/spec/integration/delayed_job_integration_spec.rb +0 -99
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'rake'
|
3
|
+
require 'apartment/migrator'
|
3
4
|
|
4
5
|
describe "apartment rake tasks" do
|
5
6
|
|
@@ -21,6 +22,10 @@ describe "apartment rake tasks" do
|
|
21
22
|
ENV['VERSION'] = nil # linux users reported env variable carrying on between tests
|
22
23
|
end
|
23
24
|
|
25
|
+
after(:all) do
|
26
|
+
Apartment::Test.load_schema
|
27
|
+
end
|
28
|
+
|
24
29
|
let(:version){ '1234' }
|
25
30
|
|
26
31
|
context 'database migration' do
|
@@ -112,7 +117,5 @@ describe "apartment rake tasks" do
|
|
112
117
|
@rake['apartment:rollback'].invoke
|
113
118
|
end
|
114
119
|
end
|
115
|
-
|
116
120
|
end
|
117
|
-
|
118
|
-
end
|
121
|
+
end
|
data/spec/unit/config_spec.rb
CHANGED
@@ -4,7 +4,7 @@ describe Apartment do
|
|
4
4
|
|
5
5
|
describe "#config" do
|
6
6
|
|
7
|
-
let(:excluded_models){ [Company] }
|
7
|
+
let(:excluded_models){ ["Company"] }
|
8
8
|
|
9
9
|
it "should yield the Apartment object" do
|
10
10
|
Apartment.configure do |config|
|
@@ -59,14 +59,14 @@ describe Apartment do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
it "should return the invoked proc if appropriate" do
|
62
|
-
dbs = lambda{ Company.
|
62
|
+
dbs = lambda{ Company.all }
|
63
63
|
|
64
64
|
Apartment.configure do |config|
|
65
65
|
config.excluded_models = []
|
66
66
|
config.database_names = dbs
|
67
67
|
end
|
68
68
|
|
69
|
-
Apartment.database_names.should == Company.
|
69
|
+
Apartment.database_names.should == Company.all
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'apartment/elevators/domain'
|
2
3
|
|
3
4
|
describe Apartment::Elevators::Domain do
|
4
5
|
|
@@ -20,7 +21,5 @@ describe Apartment::Elevators::Domain do
|
|
20
21
|
elevator = Apartment::Elevators::Domain.new(nil)
|
21
22
|
elevator.parse_database_name(request).should be_nil
|
22
23
|
end
|
23
|
-
|
24
24
|
end
|
25
|
-
|
26
25
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'apartment/elevators/host_hash'
|
2
3
|
|
3
4
|
describe Apartment::Elevators::HostHash do
|
4
5
|
|
@@ -20,7 +21,5 @@ describe Apartment::Elevators::HostHash do
|
|
20
21
|
elevator = Apartment::Elevators::HostHash.new(nil, 'example.com' => 'example_database')
|
21
22
|
expect { elevator.parse_database_name(request) }.to raise_error(Apartment::DatabaseNotFound)
|
22
23
|
end
|
23
|
-
|
24
24
|
end
|
25
|
-
|
26
25
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'apartment/elevators/subdomain'
|
2
3
|
|
3
4
|
describe Apartment::Elevators::Subdomain do
|
4
5
|
|
@@ -14,7 +15,5 @@ describe Apartment::Elevators::Subdomain do
|
|
14
15
|
elevator = Apartment::Elevators::Subdomain.new(nil)
|
15
16
|
elevator.parse_database_name(request).should be_nil
|
16
17
|
end
|
17
|
-
|
18
18
|
end
|
19
|
-
|
20
19
|
end
|
data/spec/unit/migrator_spec.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'apartment/migrator'
|
2
3
|
|
3
|
-
describe Apartment::Migrator do
|
4
|
+
describe Apartment::Migrator, database: :postgresql do
|
4
5
|
|
5
|
-
let(:config){ Apartment::Test.config['connections']['postgresql'].symbolize_keys }
|
6
6
|
let(:schema_name){ Apartment::Test.next_db }
|
7
7
|
let(:version){ 20110613152810 } # note this is brittle! I've literally just taken the version of the one migration I made... don't change this version
|
8
8
|
|
@@ -28,8 +28,10 @@ describe Apartment::Migrator do
|
|
28
28
|
Apartment::Test.drop_schema(schema_name)
|
29
29
|
end
|
30
30
|
|
31
|
-
|
31
|
+
# reset db
|
32
|
+
after(:all){ Apartment::Test.load_schema }
|
32
33
|
|
34
|
+
context "postgresql" do
|
33
35
|
context "using schemas" do
|
34
36
|
|
35
37
|
describe "#migrate" do
|
@@ -85,5 +87,4 @@ describe Apartment::Migrator do
|
|
85
87
|
end
|
86
88
|
end
|
87
89
|
end
|
88
|
-
|
89
90
|
end
|
data/spec/unit/reloader_spec.rb
CHANGED
@@ -5,7 +5,11 @@ describe Apartment::Reloader do
|
|
5
5
|
context "using postgresql schemas" do
|
6
6
|
|
7
7
|
before do
|
8
|
-
Apartment.
|
8
|
+
Apartment.configure do |config|
|
9
|
+
config.excluded_models = ["Company"]
|
10
|
+
config.use_schemas = true
|
11
|
+
end
|
12
|
+
Apartment::Database.reload!(config)
|
9
13
|
Company.reset_table_name # ensure we're clean
|
10
14
|
end
|
11
15
|
|
@@ -13,10 +17,8 @@ describe Apartment::Reloader do
|
|
13
17
|
|
14
18
|
it "should initialize apartment when called" do
|
15
19
|
Company.table_name.should_not include('public.')
|
16
|
-
subject.call(
|
20
|
+
subject.call(double('env'))
|
17
21
|
Company.table_name.should include('public.')
|
18
22
|
end
|
19
23
|
end
|
20
|
-
|
21
|
-
|
22
24
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apartment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.23.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Brunner
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-12-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -39,6 +39,118 @@ dependencies:
|
|
39
39
|
- - '>='
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: 1.3.6
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: appraisal
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rake
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ~>
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0.9'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0.9'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rspec
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ~>
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '2.11'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ~>
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '2.11'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: rspec-rails
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ~>
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '2.11'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ~>
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '2.11'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: capybara
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ~>
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: 1.0.0
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ~>
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: 1.0.0
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: mysql2
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ~>
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: 0.3.10
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ~>
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: 0.3.10
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: pg
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - '>='
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: 0.11.0
|
133
|
+
type: :development
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - '>='
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: 0.11.0
|
140
|
+
- !ruby/object:Gem::Dependency
|
141
|
+
name: sqlite3
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - '>='
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
type: :development
|
148
|
+
prerelease: false
|
149
|
+
version_requirements: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - '>='
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
42
154
|
description: Apartment allows Rack applications to deal with database multitenancy
|
43
155
|
through ActiveRecord
|
44
156
|
email:
|
@@ -54,6 +166,7 @@ files:
|
|
54
166
|
- .ruby-gemset
|
55
167
|
- .ruby-version
|
56
168
|
- .travis.yml
|
169
|
+
- Appraisals
|
57
170
|
- Gemfile
|
58
171
|
- HISTORY.md
|
59
172
|
- README.md
|
@@ -61,6 +174,10 @@ files:
|
|
61
174
|
- TODO.md
|
62
175
|
- apartment.gemspec
|
63
176
|
- circle.yml
|
177
|
+
- gemfiles/rails3.2.gemfile
|
178
|
+
- gemfiles/rails3.2.gemfile.lock
|
179
|
+
- gemfiles/rails4.0.gemfile
|
180
|
+
- gemfiles/rails4.0.gemfile.lock
|
64
181
|
- lib/apartment.rb
|
65
182
|
- lib/apartment/adapters/abstract_adapter.rb
|
66
183
|
- lib/apartment/adapters/abstract_jdbc_adapter.rb
|
@@ -72,11 +189,6 @@ files:
|
|
72
189
|
- lib/apartment/adapters/sqlite3_adapter.rb
|
73
190
|
- lib/apartment/console.rb
|
74
191
|
- lib/apartment/database.rb
|
75
|
-
- lib/apartment/delayed_job/enqueue.rb
|
76
|
-
- lib/apartment/delayed_job/hooks.rb
|
77
|
-
- lib/apartment/delayed_job/psych_ext.rb
|
78
|
-
- lib/apartment/delayed_job/requirements.rb
|
79
|
-
- lib/apartment/delayed_job/syck_ext.rb
|
80
192
|
- lib/apartment/elevators/domain.rb
|
81
193
|
- lib/apartment/elevators/first_subdomain.rb
|
82
194
|
- lib/apartment/elevators/generic.rb
|
@@ -126,7 +238,6 @@ files:
|
|
126
238
|
- spec/dummy/db/schema.rb
|
127
239
|
- spec/dummy/db/seeds.rb
|
128
240
|
- spec/dummy/db/test.sqlite3
|
129
|
-
- spec/dummy/lib/fake_dj_class.rb
|
130
241
|
- spec/dummy/public/404.html
|
131
242
|
- spec/dummy/public/422.html
|
132
243
|
- spec/dummy/public/500.html
|
@@ -138,21 +249,24 @@ files:
|
|
138
249
|
- spec/examples/generic_adapter_examples.rb
|
139
250
|
- spec/examples/schema_adapter_examples.rb
|
140
251
|
- spec/integration/apartment_rake_integration_spec.rb
|
141
|
-
- spec/integration/delayed_job_integration_spec.rb
|
142
252
|
- spec/integration/middleware/domain_elevator_spec.rb
|
143
|
-
- spec/integration/middleware/first_subdomain_elevator_spec.rb
|
144
253
|
- spec/integration/middleware/generic_elevator_spec.rb
|
145
254
|
- spec/integration/middleware/subdomain_elevator_spec.rb
|
146
255
|
- spec/integration/query_caching_spec.rb
|
256
|
+
- spec/schemas/v1.rb
|
257
|
+
- spec/schemas/v2.rb
|
258
|
+
- spec/schemas/v3.rb
|
147
259
|
- spec/spec_helper.rb
|
148
260
|
- spec/support/apartment_helpers.rb
|
149
261
|
- spec/support/capybara_sessions.rb
|
150
262
|
- spec/support/config.rb
|
151
263
|
- spec/support/contexts.rb
|
152
264
|
- spec/support/requirements.rb
|
265
|
+
- spec/support/setup.rb
|
153
266
|
- spec/tasks/apartment_rake_spec.rb
|
154
267
|
- spec/unit/config_spec.rb
|
155
268
|
- spec/unit/middleware/domain_elevator_spec.rb
|
269
|
+
- spec/unit/middleware/first_subdomain_elevator_spec.rb
|
156
270
|
- spec/unit/middleware/host_hash_elevator_spec.rb
|
157
271
|
- spec/unit/middleware/subdomain_elevator_spec.rb
|
158
272
|
- spec/unit/migrator_spec.rb
|
@@ -177,7 +291,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
177
291
|
version: '0'
|
178
292
|
requirements: []
|
179
293
|
rubyforge_project:
|
180
|
-
rubygems_version: 2.
|
294
|
+
rubygems_version: 2.1.10
|
181
295
|
signing_key:
|
182
296
|
specification_version: 4
|
183
297
|
summary: A Ruby gem for managing database multitenancy
|
@@ -218,7 +332,6 @@ test_files:
|
|
218
332
|
- spec/dummy/db/schema.rb
|
219
333
|
- spec/dummy/db/seeds.rb
|
220
334
|
- spec/dummy/db/test.sqlite3
|
221
|
-
- spec/dummy/lib/fake_dj_class.rb
|
222
335
|
- spec/dummy/public/404.html
|
223
336
|
- spec/dummy/public/422.html
|
224
337
|
- spec/dummy/public/500.html
|
@@ -230,21 +343,24 @@ test_files:
|
|
230
343
|
- spec/examples/generic_adapter_examples.rb
|
231
344
|
- spec/examples/schema_adapter_examples.rb
|
232
345
|
- spec/integration/apartment_rake_integration_spec.rb
|
233
|
-
- spec/integration/delayed_job_integration_spec.rb
|
234
346
|
- spec/integration/middleware/domain_elevator_spec.rb
|
235
|
-
- spec/integration/middleware/first_subdomain_elevator_spec.rb
|
236
347
|
- spec/integration/middleware/generic_elevator_spec.rb
|
237
348
|
- spec/integration/middleware/subdomain_elevator_spec.rb
|
238
349
|
- spec/integration/query_caching_spec.rb
|
350
|
+
- spec/schemas/v1.rb
|
351
|
+
- spec/schemas/v2.rb
|
352
|
+
- spec/schemas/v3.rb
|
239
353
|
- spec/spec_helper.rb
|
240
354
|
- spec/support/apartment_helpers.rb
|
241
355
|
- spec/support/capybara_sessions.rb
|
242
356
|
- spec/support/config.rb
|
243
357
|
- spec/support/contexts.rb
|
244
358
|
- spec/support/requirements.rb
|
359
|
+
- spec/support/setup.rb
|
245
360
|
- spec/tasks/apartment_rake_spec.rb
|
246
361
|
- spec/unit/config_spec.rb
|
247
362
|
- spec/unit/middleware/domain_elevator_spec.rb
|
363
|
+
- spec/unit/middleware/first_subdomain_elevator_spec.rb
|
248
364
|
- spec/unit/middleware/host_hash_elevator_spec.rb
|
249
365
|
- spec/unit/middleware/subdomain_elevator_spec.rb
|
250
366
|
- spec/unit/migrator_spec.rb
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'delayed_job'
|
2
|
-
require 'yaml'
|
3
|
-
|
4
|
-
if YAML.parser.class.name =~ /syck|yecht/i
|
5
|
-
require 'apartment/delayed_job/syck_ext'
|
6
|
-
else
|
7
|
-
require 'apartment/delayed_job/psych_ext'
|
8
|
-
end
|
9
|
-
|
10
|
-
module Apartment
|
11
|
-
module Delayed
|
12
|
-
module Job
|
13
|
-
|
14
|
-
# Will enqueue a job ensuring that it happens within the main 'public' database
|
15
|
-
#
|
16
|
-
# Note that this should not longer be required for versions >= 0.11.0 when using postgresql schemas
|
17
|
-
#
|
18
|
-
def self.enqueue(payload_object, options = {})
|
19
|
-
Apartment::Database.process do
|
20
|
-
::Delayed::Job.enqueue(payload_object, options)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'apartment/delayed_job/enqueue'
|
2
|
-
|
3
|
-
module Apartment
|
4
|
-
module Delayed
|
5
|
-
module Job
|
6
|
-
|
7
|
-
# Before and after hooks for performing Delayed Jobs within a particular apartment database
|
8
|
-
# Include these in your delayed jobs models and make sure provide a @database attr that will be serialized by DJ
|
9
|
-
# Note also that any models that are being serialized need the Apartment::Delayed::Requirements module mixed in to it
|
10
|
-
module Hooks
|
11
|
-
|
12
|
-
attr_accessor :database
|
13
|
-
|
14
|
-
def before(job)
|
15
|
-
@_current_database = Apartment::Database.current_database
|
16
|
-
Apartment::Database.switch(job.payload_object.database) if job.payload_object.database
|
17
|
-
end
|
18
|
-
|
19
|
-
def after
|
20
|
-
Apartment::Database.switch(@_current_database)
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|