activerecord-multi-tenant 1.2.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/active-record-multi-tenant-tests.yml +83 -0
- data/.gitignore +6 -0
- data/.readthedocs.yaml +15 -0
- data/.rspec +0 -0
- data/.rubocop.yml +51 -0
- data/Appraisals +6 -22
- data/CHANGELOG.md +51 -0
- data/Gemfile +3 -1
- data/LICENSE +0 -0
- data/README.md +3 -2
- data/Rakefile +1 -1
- data/activerecord-multi-tenant.gemspec +28 -23
- data/docker-compose.yml +24 -18
- data/docs/.gitignore +3 -0
- data/docs/Makefile +28 -0
- data/docs/api-reference.sh +10 -0
- data/docs/requirements.in +4 -0
- data/docs/requirements.txt +62 -0
- data/docs/source/_static/api-reference/ActiveRecord/Associations/Association.html +285 -0
- data/docs/source/_static/api-reference/ActiveRecord/Associations/ClassMethods.html +255 -0
- data/docs/source/_static/api-reference/ActiveRecord/Associations.html +117 -0
- data/docs/source/_static/api-reference/ActiveRecord/ConnectionAdapters/SchemaStatements.html +232 -0
- data/docs/source/_static/api-reference/ActiveRecord/ConnectionAdapters.html +126 -0
- data/docs/source/_static/api-reference/ActiveRecord/QueryMethods.html +336 -0
- data/docs/source/_static/api-reference/ActiveRecord/SchemaDumper.html +121 -0
- data/docs/source/_static/api-reference/ActiveRecord.html +130 -0
- data/docs/source/_static/api-reference/MultiTenant/ArelTenantVisitor.html +755 -0
- data/docs/source/_static/api-reference/MultiTenant/ArelVisitorsDepthFirst.html +208 -0
- data/docs/source/_static/api-reference/MultiTenant/BaseTenantEnforcementClause.html +462 -0
- data/docs/source/_static/api-reference/MultiTenant/Context.html +659 -0
- data/docs/source/_static/api-reference/MultiTenant/ControllerExtensions.html +202 -0
- data/docs/source/_static/api-reference/MultiTenant/CopyFromClient.html +186 -0
- data/docs/source/_static/api-reference/MultiTenant/CopyFromClientHelper.html +362 -0
- data/docs/source/_static/api-reference/MultiTenant/Current.html +124 -0
- data/docs/source/_static/api-reference/MultiTenant/DatabaseStatements.html +366 -0
- data/docs/source/_static/api-reference/MultiTenant/FastTruncate.html +226 -0
- data/docs/source/_static/api-reference/MultiTenant/MigrationExtensions.html +554 -0
- data/docs/source/_static/api-reference/MultiTenant/MissingTenantError.html +124 -0
- data/docs/source/_static/api-reference/MultiTenant/ModelExtensionsClassMethods.html +492 -0
- data/docs/source/_static/api-reference/MultiTenant/QueryMonitor.html +257 -0
- data/docs/source/_static/api-reference/MultiTenant/Table.html +419 -0
- data/docs/source/_static/api-reference/MultiTenant/TenantEnforcementClause.html +148 -0
- data/docs/source/_static/api-reference/MultiTenant/TenantIsImmutable.html +135 -0
- data/docs/source/_static/api-reference/MultiTenant/TenantJoinEnforcementClause.html +310 -0
- data/docs/source/_static/api-reference/MultiTenant/TenantValueVisitor.html +239 -0
- data/docs/source/_static/api-reference/MultiTenant.html +1454 -0
- data/docs/source/_static/api-reference/MultiTenantFindBy.html +180 -0
- data/docs/source/_static/api-reference/Sidekiq/Client.html +302 -0
- data/docs/source/_static/api-reference/Sidekiq/Middleware/MultiTenant/Client.html +217 -0
- data/docs/source/_static/api-reference/Sidekiq/Middleware/MultiTenant/Server.html +219 -0
- data/docs/source/_static/api-reference/Sidekiq/Middleware/MultiTenant.html +126 -0
- data/docs/source/_static/api-reference/Sidekiq.html +126 -0
- data/docs/source/_static/api-reference/_index.html +399 -0
- data/docs/source/_static/api-reference/class_list.html +51 -0
- data/docs/source/_static/api-reference/css/common.css +1 -0
- data/docs/source/_static/api-reference/css/full_list.css +58 -0
- data/docs/source/_static/api-reference/css/style.css +497 -0
- data/docs/source/_static/api-reference/file.README.html +167 -0
- data/docs/source/_static/api-reference/file_list.html +56 -0
- data/docs/source/_static/api-reference/frames.html +17 -0
- data/docs/source/_static/api-reference/index.html +167 -0
- data/docs/source/_static/api-reference/js/app.js +314 -0
- data/docs/source/_static/api-reference/js/full_list.js +216 -0
- data/docs/source/_static/api-reference/js/jquery.js +4 -0
- data/docs/source/_static/api-reference/method_list.html +715 -0
- data/docs/source/_static/api-reference/top-level-namespace.html +126 -0
- data/docs/source/_templates/.gitignore +4 -0
- data/docs/source/api-reference.rst +8 -0
- data/docs/source/appendix.rst +26 -0
- data/docs/source/changelog.rst +8 -0
- data/docs/source/community-and-support.rst +26 -0
- data/docs/source/conf.py +30 -0
- data/docs/source/contributing.rst +70 -0
- data/docs/source/getting-started.rst +37 -0
- data/docs/source/guides-and-tutorials.rst +129 -0
- data/docs/source/index.rst +54 -0
- data/docs/source/introduction.rst +33 -0
- data/docs/source/license.rst +22 -0
- data/docs/source/troubleshooting.rst +41 -0
- data/docs/source/usage-guide.rst +59 -0
- data/lib/activerecord-multi-tenant/arel_visitors_depth_first.rb +183 -174
- data/lib/activerecord-multi-tenant/controller_extensions.rb +15 -4
- data/lib/activerecord-multi-tenant/copy_from_client.rb +4 -0
- data/lib/activerecord-multi-tenant/fast_truncate.rb +4 -2
- data/lib/activerecord-multi-tenant/habtm.rb +50 -0
- data/lib/activerecord-multi-tenant/migrations.rb +87 -10
- data/lib/activerecord-multi-tenant/model_extensions.rb +98 -34
- data/lib/activerecord-multi-tenant/multi_tenant.rb +102 -29
- data/lib/activerecord-multi-tenant/query_monitor.rb +21 -5
- data/lib/activerecord-multi-tenant/query_rewriter.rb +122 -91
- data/lib/activerecord-multi-tenant/sidekiq.rb +46 -19
- data/lib/activerecord-multi-tenant/table_node.rb +13 -0
- data/lib/activerecord-multi-tenant/version.rb +1 -1
- data/lib/activerecord-multi-tenant.rb +3 -13
- data/lib/activerecord_multi_tenant.rb +13 -0
- data/spec/activerecord-multi-tenant/associations_spec.rb +42 -0
- data/spec/activerecord-multi-tenant/controller_extensions_spec.rb +3 -2
- data/spec/activerecord-multi-tenant/fast_truncate_spec.rb +8 -6
- data/spec/activerecord-multi-tenant/model_extensions_spec.rb +347 -143
- data/spec/activerecord-multi-tenant/multi_tenant_spec.rb +69 -13
- data/spec/activerecord-multi-tenant/query_rewriter_spec.rb +60 -59
- data/spec/activerecord-multi-tenant/record_callback_spec.rb +0 -0
- data/spec/activerecord-multi-tenant/record_finding_spec.rb +11 -11
- data/spec/activerecord-multi-tenant/record_modifications_spec.rb +23 -4
- data/spec/activerecord-multi-tenant/sidekiq_spec.rb +10 -10
- data/spec/database.yml +0 -0
- data/spec/schema.rb +43 -2
- data/spec/spec_helper.rb +52 -16
- data/spec/support/format_sql.rb +20 -0
- metadata +126 -36
- data/.github/workflows/CI.yml +0 -63
- data/gemfiles/.bundle/config +0 -2
- data/gemfiles/active_record_5.2.gemfile +0 -16
- data/gemfiles/active_record_6.0.gemfile +0 -8
- data/gemfiles/active_record_6.1.gemfile +0 -8
- data/gemfiles/active_record_7.0.gemfile +0 -8
- data/gemfiles/rails_5.2.gemfile +0 -16
- data/gemfiles/rails_6.0.gemfile +0 -8
- data/gemfiles/rails_6.1.gemfile +0 -8
- data/gemfiles/rails_7.0.gemfile +0 -8
- data/lib/activerecord-multi-tenant/persistence_extension.rb +0 -13
- data/lib/activerecord-multi-tenant/with_lock.rb +0 -15
- data/spec/activerecord-multi-tenant/schema_dumper_tester.rb +0 -0
@@ -0,0 +1,1454 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
Module: MultiTenant
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.34
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" />
|
16
|
+
|
17
|
+
<script type="text/javascript">
|
18
|
+
pathId = "MultiTenant";
|
19
|
+
relpath = '';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="_index.html">Index (M)</a> »
|
40
|
+
|
41
|
+
|
42
|
+
<span class="title">MultiTenant</span>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="search">
|
47
|
+
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
49
|
+
href="class_list.html">
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div id="content"><h1>Module: MultiTenant
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<dl>
|
80
|
+
<dt>Defined in:</dt>
|
81
|
+
<dd>lib/activerecord-multi-tenant/fast_truncate.rb<span class="defines">,<br />
|
82
|
+
lib/activerecord-multi-tenant/version.rb,<br /> lib/activerecord-multi-tenant/migrations.rb,<br /> lib/activerecord-multi-tenant/multi_tenant.rb,<br /> lib/activerecord-multi-tenant/query_monitor.rb,<br /> lib/activerecord-multi-tenant/query_rewriter.rb,<br /> lib/activerecord-multi-tenant/copy_from_client.rb,<br /> lib/activerecord-multi-tenant/model_extensions.rb,<br /> lib/activerecord-multi-tenant/controller_extensions.rb,<br /> lib/activerecord-multi-tenant/arel_visitors_depth_first.rb</span>
|
83
|
+
</dd>
|
84
|
+
</dl>
|
85
|
+
|
86
|
+
</div>
|
87
|
+
|
88
|
+
<h2>Overview</h2><div class="docstring">
|
89
|
+
<div class="discussion">
|
90
|
+
|
91
|
+
<p>Extension to the controller to allow setting the current tenant set_current_tenant and current_tenant methods are introduced to set and get the current tenant in the controllers that uses the MultiTenant module.</p>
|
92
|
+
|
93
|
+
|
94
|
+
</div>
|
95
|
+
</div>
|
96
|
+
<div class="tags">
|
97
|
+
|
98
|
+
|
99
|
+
</div><h2>Defined Under Namespace</h2>
|
100
|
+
<p class="children">
|
101
|
+
|
102
|
+
|
103
|
+
<strong class="modules">Modules:</strong> <span class='object_link'><a href="MultiTenant/ControllerExtensions.html" title="MultiTenant::ControllerExtensions (module)">ControllerExtensions</a></span>, <span class='object_link'><a href="MultiTenant/CopyFromClient.html" title="MultiTenant::CopyFromClient (module)">CopyFromClient</a></span>, <span class='object_link'><a href="MultiTenant/DatabaseStatements.html" title="MultiTenant::DatabaseStatements (module)">DatabaseStatements</a></span>, <span class='object_link'><a href="MultiTenant/FastTruncate.html" title="MultiTenant::FastTruncate (module)">FastTruncate</a></span>, <span class='object_link'><a href="MultiTenant/MigrationExtensions.html" title="MultiTenant::MigrationExtensions (module)">MigrationExtensions</a></span>, <span class='object_link'><a href="MultiTenant/ModelExtensionsClassMethods.html" title="MultiTenant::ModelExtensionsClassMethods (module)">ModelExtensionsClassMethods</a></span>, <span class='object_link'><a href="MultiTenant/TenantValueVisitor.html" title="MultiTenant::TenantValueVisitor (module)">TenantValueVisitor</a></span>
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
<strong class="classes">Classes:</strong> <span class='object_link'><a href="MultiTenant/ArelTenantVisitor.html" title="MultiTenant::ArelTenantVisitor (class)">ArelTenantVisitor</a></span>, <span class='object_link'><a href="MultiTenant/ArelVisitorsDepthFirst.html" title="MultiTenant::ArelVisitorsDepthFirst (class)">ArelVisitorsDepthFirst</a></span>, <span class='object_link'><a href="MultiTenant/BaseTenantEnforcementClause.html" title="MultiTenant::BaseTenantEnforcementClause (class)">BaseTenantEnforcementClause</a></span>, <span class='object_link'><a href="MultiTenant/Context.html" title="MultiTenant::Context (class)">Context</a></span>, <span class='object_link'><a href="MultiTenant/CopyFromClientHelper.html" title="MultiTenant::CopyFromClientHelper (class)">CopyFromClientHelper</a></span>, <span class='object_link'><a href="MultiTenant/Current.html" title="MultiTenant::Current (class)">Current</a></span>, <span class='object_link'><a href="MultiTenant/MissingTenantError.html" title="MultiTenant::MissingTenantError (class)">MissingTenantError</a></span>, <span class='object_link'><a href="MultiTenant/QueryMonitor.html" title="MultiTenant::QueryMonitor (class)">QueryMonitor</a></span>, <span class='object_link'><a href="MultiTenant/Table.html" title="MultiTenant::Table (class)">Table</a></span>, <span class='object_link'><a href="MultiTenant/TenantEnforcementClause.html" title="MultiTenant::TenantEnforcementClause (class)">TenantEnforcementClause</a></span>, <span class='object_link'><a href="MultiTenant/TenantIsImmutable.html" title="MultiTenant::TenantIsImmutable (class)">TenantIsImmutable</a></span>, <span class='object_link'><a href="MultiTenant/TenantJoinEnforcementClause.html" title="MultiTenant::TenantJoinEnforcementClause (class)">TenantJoinEnforcementClause</a></span>
|
108
|
+
|
109
|
+
|
110
|
+
</p>
|
111
|
+
|
112
|
+
|
113
|
+
<h2>
|
114
|
+
Constant Summary
|
115
|
+
<small><a href="#" class="constants_summary_toggle">collapse</a></small>
|
116
|
+
</h2>
|
117
|
+
|
118
|
+
<dl class="constants">
|
119
|
+
|
120
|
+
<dt id="VERSION-constant" class="">VERSION =
|
121
|
+
|
122
|
+
</dt>
|
123
|
+
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>2.2.0</span><span class='tstring_end'>'</span></span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
|
124
|
+
|
125
|
+
<dt id="enable_query_monitor-classvariable" class="">@@enable_query_monitor =
|
126
|
+
<div class="docstring">
|
127
|
+
<div class="discussion">
|
128
|
+
|
129
|
+
<p>rubocop:disable Style/ClassVars Option to enable query monitor</p>
|
130
|
+
|
131
|
+
|
132
|
+
</div>
|
133
|
+
</div>
|
134
|
+
<div class="tags">
|
135
|
+
|
136
|
+
|
137
|
+
</div>
|
138
|
+
</dt>
|
139
|
+
<dd><pre class="code"><span class='kw'>false</span></pre></dd>
|
140
|
+
|
141
|
+
</dl>
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
<h2>
|
152
|
+
Class Method Summary
|
153
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
154
|
+
</h2>
|
155
|
+
|
156
|
+
<ul class="summary">
|
157
|
+
|
158
|
+
<li class="public ">
|
159
|
+
<span class="summary_signature">
|
160
|
+
|
161
|
+
<a href="#current_tenant-class_method" title="current_tenant (class method)">.<strong>current_tenant</strong> ⇒ Object </a>
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
</span>
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
176
|
+
|
177
|
+
</li>
|
178
|
+
|
179
|
+
|
180
|
+
<li class="public ">
|
181
|
+
<span class="summary_signature">
|
182
|
+
|
183
|
+
<a href="#current_tenant=-class_method" title="current_tenant= (class method)">.<strong>current_tenant=</strong>(tenant) ⇒ Object </a>
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
</span>
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
198
|
+
|
199
|
+
</li>
|
200
|
+
|
201
|
+
|
202
|
+
<li class="public ">
|
203
|
+
<span class="summary_signature">
|
204
|
+
|
205
|
+
<a href="#current_tenant_class-class_method" title="current_tenant_class (class method)">.<strong>current_tenant_class</strong> ⇒ Object </a>
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
</span>
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
220
|
+
|
221
|
+
</li>
|
222
|
+
|
223
|
+
|
224
|
+
<li class="public ">
|
225
|
+
<span class="summary_signature">
|
226
|
+
|
227
|
+
<a href="#current_tenant_id-class_method" title="current_tenant_id (class method)">.<strong>current_tenant_id</strong> ⇒ Object </a>
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
</span>
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
242
|
+
|
243
|
+
</li>
|
244
|
+
|
245
|
+
|
246
|
+
<li class="public ">
|
247
|
+
<span class="summary_signature">
|
248
|
+
|
249
|
+
<a href="#current_tenant_is_id%3F-class_method" title="current_tenant_is_id? (class method)">.<strong>current_tenant_is_id?</strong> ⇒ Boolean </a>
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
</span>
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
264
|
+
|
265
|
+
</li>
|
266
|
+
|
267
|
+
|
268
|
+
<li class="public ">
|
269
|
+
<span class="summary_signature">
|
270
|
+
|
271
|
+
<a href="#default_tenant_class-class_method" title="default_tenant_class (class method)">.<strong>default_tenant_class</strong> ⇒ Object </a>
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
</span>
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
286
|
+
|
287
|
+
</li>
|
288
|
+
|
289
|
+
|
290
|
+
<li class="public ">
|
291
|
+
<span class="summary_signature">
|
292
|
+
|
293
|
+
<a href="#default_tenant_class=-class_method" title="default_tenant_class= (class method)">.<strong>default_tenant_class=</strong>(tenant_class) ⇒ Object </a>
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
</span>
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
<span class="summary_desc"><div class='inline'>
|
308
|
+
<p>rubocop:disable Style/ClassVars In some cases we only have an ID - if defined we’ll return the default tenant class in such cases.</p>
|
309
|
+
</div></span>
|
310
|
+
|
311
|
+
</li>
|
312
|
+
|
313
|
+
|
314
|
+
<li class="public ">
|
315
|
+
<span class="summary_signature">
|
316
|
+
|
317
|
+
<a href="#enable_query_monitor-class_method" title="enable_query_monitor (class method)">.<strong>enable_query_monitor</strong> ⇒ Object </a>
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
</span>
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
332
|
+
|
333
|
+
</li>
|
334
|
+
|
335
|
+
|
336
|
+
<li class="public ">
|
337
|
+
<span class="summary_signature">
|
338
|
+
|
339
|
+
<a href="#enable_write_only_mode-class_method" title="enable_write_only_mode (class method)">.<strong>enable_write_only_mode</strong> ⇒ Object </a>
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
</span>
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
<span class="summary_desc"><div class='inline'>
|
354
|
+
<p>Write-only Mode - this only adds the tenant_id to new records, but doesn’t require its presence for SELECTs/UPDATEs/DELETEs.</p>
|
355
|
+
</div></span>
|
356
|
+
|
357
|
+
</li>
|
358
|
+
|
359
|
+
|
360
|
+
<li class="public ">
|
361
|
+
<span class="summary_signature">
|
362
|
+
|
363
|
+
<a href="#load_current_tenant!-class_method" title="load_current_tenant! (class method)">.<strong>load_current_tenant!</strong> ⇒ Object </a>
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
</span>
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
|
376
|
+
|
377
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
378
|
+
|
379
|
+
</li>
|
380
|
+
|
381
|
+
|
382
|
+
<li class="public ">
|
383
|
+
<span class="summary_signature">
|
384
|
+
|
385
|
+
<a href="#multi_tenant_model_for_arel-class_method" title="multi_tenant_model_for_arel (class method)">.<strong>multi_tenant_model_for_arel</strong>(arel) ⇒ Object </a>
|
386
|
+
|
387
|
+
|
388
|
+
|
389
|
+
</span>
|
390
|
+
|
391
|
+
|
392
|
+
|
393
|
+
|
394
|
+
|
395
|
+
|
396
|
+
|
397
|
+
|
398
|
+
|
399
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
400
|
+
|
401
|
+
</li>
|
402
|
+
|
403
|
+
|
404
|
+
<li class="public ">
|
405
|
+
<span class="summary_signature">
|
406
|
+
|
407
|
+
<a href="#multi_tenant_model_for_table-class_method" title="multi_tenant_model_for_table (class method)">.<strong>multi_tenant_model_for_table</strong>(table_name) ⇒ Object </a>
|
408
|
+
|
409
|
+
|
410
|
+
|
411
|
+
</span>
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
|
416
|
+
|
417
|
+
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
422
|
+
|
423
|
+
</li>
|
424
|
+
|
425
|
+
|
426
|
+
<li class="public ">
|
427
|
+
<span class="summary_signature">
|
428
|
+
|
429
|
+
<a href="#partition_key-class_method" title="partition_key (class method)">.<strong>partition_key</strong>(tenant_name) ⇒ Object </a>
|
430
|
+
|
431
|
+
|
432
|
+
|
433
|
+
</span>
|
434
|
+
|
435
|
+
|
436
|
+
|
437
|
+
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
|
442
|
+
|
443
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
444
|
+
|
445
|
+
</li>
|
446
|
+
|
447
|
+
|
448
|
+
<li class="public ">
|
449
|
+
<span class="summary_signature">
|
450
|
+
|
451
|
+
<a href="#query_monitor_enabled%3F-class_method" title="query_monitor_enabled? (class method)">.<strong>query_monitor_enabled?</strong> ⇒ Boolean </a>
|
452
|
+
|
453
|
+
|
454
|
+
|
455
|
+
</span>
|
456
|
+
|
457
|
+
|
458
|
+
|
459
|
+
|
460
|
+
|
461
|
+
|
462
|
+
|
463
|
+
|
464
|
+
|
465
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
466
|
+
|
467
|
+
</li>
|
468
|
+
|
469
|
+
|
470
|
+
<li class="public ">
|
471
|
+
<span class="summary_signature">
|
472
|
+
|
473
|
+
<a href="#register_multi_tenant_model-class_method" title="register_multi_tenant_model (class method)">.<strong>register_multi_tenant_model</strong>(model_klass) ⇒ Object </a>
|
474
|
+
|
475
|
+
|
476
|
+
|
477
|
+
</span>
|
478
|
+
|
479
|
+
|
480
|
+
|
481
|
+
|
482
|
+
|
483
|
+
|
484
|
+
|
485
|
+
|
486
|
+
|
487
|
+
<span class="summary_desc"><div class='inline'>
|
488
|
+
<p>Registry that maps table names to models (used by the query rewriter).</p>
|
489
|
+
</div></span>
|
490
|
+
|
491
|
+
</li>
|
492
|
+
|
493
|
+
|
494
|
+
<li class="public ">
|
495
|
+
<span class="summary_signature">
|
496
|
+
|
497
|
+
<a href="#tenant_klass_defined%3F-class_method" title="tenant_klass_defined? (class method)">.<strong>tenant_klass_defined?</strong>(tenant_name) ⇒ Boolean </a>
|
498
|
+
|
499
|
+
|
500
|
+
|
501
|
+
</span>
|
502
|
+
|
503
|
+
|
504
|
+
|
505
|
+
|
506
|
+
|
507
|
+
|
508
|
+
|
509
|
+
|
510
|
+
|
511
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
512
|
+
|
513
|
+
</li>
|
514
|
+
|
515
|
+
|
516
|
+
<li class="public ">
|
517
|
+
<span class="summary_signature">
|
518
|
+
|
519
|
+
<a href="#with-class_method" title="with (class method)">.<strong>with</strong>(tenant, &block) ⇒ Object </a>
|
520
|
+
|
521
|
+
|
522
|
+
|
523
|
+
</span>
|
524
|
+
|
525
|
+
|
526
|
+
|
527
|
+
|
528
|
+
|
529
|
+
|
530
|
+
|
531
|
+
|
532
|
+
|
533
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
534
|
+
|
535
|
+
</li>
|
536
|
+
|
537
|
+
|
538
|
+
<li class="public ">
|
539
|
+
<span class="summary_signature">
|
540
|
+
|
541
|
+
<a href="#with_write_only_mode_enabled%3F-class_method" title="with_write_only_mode_enabled? (class method)">.<strong>with_write_only_mode_enabled?</strong> ⇒ Boolean </a>
|
542
|
+
|
543
|
+
|
544
|
+
|
545
|
+
</span>
|
546
|
+
|
547
|
+
|
548
|
+
|
549
|
+
|
550
|
+
|
551
|
+
|
552
|
+
|
553
|
+
|
554
|
+
|
555
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
556
|
+
|
557
|
+
</li>
|
558
|
+
|
559
|
+
|
560
|
+
<li class="public ">
|
561
|
+
<span class="summary_signature">
|
562
|
+
|
563
|
+
<a href="#without-class_method" title="without (class method)">.<strong>without</strong>(&block) ⇒ Object </a>
|
564
|
+
|
565
|
+
|
566
|
+
|
567
|
+
</span>
|
568
|
+
|
569
|
+
|
570
|
+
|
571
|
+
|
572
|
+
|
573
|
+
|
574
|
+
|
575
|
+
|
576
|
+
|
577
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
578
|
+
|
579
|
+
</li>
|
580
|
+
|
581
|
+
|
582
|
+
<li class="public ">
|
583
|
+
<span class="summary_signature">
|
584
|
+
|
585
|
+
<a href="#wrap_methods-class_method" title="wrap_methods (class method)">.<strong>wrap_methods</strong>(klass, owner, *method_names) ⇒ Object </a>
|
586
|
+
|
587
|
+
|
588
|
+
|
589
|
+
</span>
|
590
|
+
|
591
|
+
|
592
|
+
|
593
|
+
|
594
|
+
|
595
|
+
|
596
|
+
|
597
|
+
|
598
|
+
|
599
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
600
|
+
|
601
|
+
</li>
|
602
|
+
|
603
|
+
|
604
|
+
</ul>
|
605
|
+
|
606
|
+
|
607
|
+
|
608
|
+
|
609
|
+
<div id="class_method_details" class="method_details_list">
|
610
|
+
<h2>Class Method Details</h2>
|
611
|
+
|
612
|
+
|
613
|
+
<div class="method_details first">
|
614
|
+
<h3 class="signature first" id="current_tenant-class_method">
|
615
|
+
|
616
|
+
.<strong>current_tenant</strong> ⇒ <tt>Object</tt>
|
617
|
+
|
618
|
+
|
619
|
+
|
620
|
+
|
621
|
+
|
622
|
+
</h3><table class="source_code">
|
623
|
+
<tr>
|
624
|
+
<td>
|
625
|
+
<pre class="lines">
|
626
|
+
|
627
|
+
|
628
|
+
71
|
629
|
+
72
|
630
|
+
73</pre>
|
631
|
+
</td>
|
632
|
+
<td>
|
633
|
+
<pre class="code"><span class="info file"># File 'lib/activerecord-multi-tenant/multi_tenant.rb', line 71</span>
|
634
|
+
|
635
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_current_tenant'>current_tenant</span>
|
636
|
+
<span class='const'><span class='object_link'><a href="MultiTenant/Current.html" title="MultiTenant::Current (class)">Current</a></span></span><span class='period'>.</span><span class='id identifier rubyid_tenant'>tenant</span>
|
637
|
+
<span class='kw'>end</span></pre>
|
638
|
+
</td>
|
639
|
+
</tr>
|
640
|
+
</table>
|
641
|
+
</div>
|
642
|
+
|
643
|
+
<div class="method_details ">
|
644
|
+
<h3 class="signature " id="current_tenant=-class_method">
|
645
|
+
|
646
|
+
.<strong>current_tenant=</strong>(tenant) ⇒ <tt>Object</tt>
|
647
|
+
|
648
|
+
|
649
|
+
|
650
|
+
|
651
|
+
|
652
|
+
</h3><table class="source_code">
|
653
|
+
<tr>
|
654
|
+
<td>
|
655
|
+
<pre class="lines">
|
656
|
+
|
657
|
+
|
658
|
+
67
|
659
|
+
68
|
660
|
+
69</pre>
|
661
|
+
</td>
|
662
|
+
<td>
|
663
|
+
<pre class="code"><span class="info file"># File 'lib/activerecord-multi-tenant/multi_tenant.rb', line 67</span>
|
664
|
+
|
665
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_current_tenant='>current_tenant=</span><span class='lparen'>(</span><span class='id identifier rubyid_tenant'>tenant</span><span class='rparen'>)</span>
|
666
|
+
<span class='const'><span class='object_link'><a href="MultiTenant/Current.html" title="MultiTenant::Current (class)">Current</a></span></span><span class='period'>.</span><span class='id identifier rubyid_tenant'>tenant</span> <span class='op'>=</span> <span class='id identifier rubyid_tenant'>tenant</span>
|
667
|
+
<span class='kw'>end</span></pre>
|
668
|
+
</td>
|
669
|
+
</tr>
|
670
|
+
</table>
|
671
|
+
</div>
|
672
|
+
|
673
|
+
<div class="method_details ">
|
674
|
+
<h3 class="signature " id="current_tenant_class-class_method">
|
675
|
+
|
676
|
+
.<strong>current_tenant_class</strong> ⇒ <tt>Object</tt>
|
677
|
+
|
678
|
+
|
679
|
+
|
680
|
+
|
681
|
+
|
682
|
+
</h3><table class="source_code">
|
683
|
+
<tr>
|
684
|
+
<td>
|
685
|
+
<pre class="lines">
|
686
|
+
|
687
|
+
|
688
|
+
83
|
689
|
+
84
|
690
|
+
85
|
691
|
+
86
|
692
|
+
87
|
693
|
+
88
|
694
|
+
89</pre>
|
695
|
+
</td>
|
696
|
+
<td>
|
697
|
+
<pre class="code"><span class="info file"># File 'lib/activerecord-multi-tenant/multi_tenant.rb', line 83</span>
|
698
|
+
|
699
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_current_tenant_class'>current_tenant_class</span>
|
700
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_current_tenant_is_id?'>current_tenant_is_id?</span>
|
701
|
+
<span class='const'><span class='object_link'><a href="" title="MultiTenant (module)">MultiTenant</a></span></span><span class='period'>.</span><span class='id identifier rubyid_default_tenant_class'><span class='object_link'><a href="#default_tenant_class-class_method" title="MultiTenant.default_tenant_class (method)">default_tenant_class</a></span></span> <span class='op'>||</span> <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Only have tenant id, and no default tenant class set</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
702
|
+
<span class='kw'>elsif</span> <span class='id identifier rubyid_current_tenant'>current_tenant</span>
|
703
|
+
<span class='const'><span class='object_link'><a href="" title="MultiTenant (module)">MultiTenant</a></span></span><span class='period'>.</span><span class='id identifier rubyid_current_tenant'><span class='object_link'><a href="#current_tenant-class_method" title="MultiTenant.current_tenant (method)">current_tenant</a></span></span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span>
|
704
|
+
<span class='kw'>end</span>
|
705
|
+
<span class='kw'>end</span></pre>
|
706
|
+
</td>
|
707
|
+
</tr>
|
708
|
+
</table>
|
709
|
+
</div>
|
710
|
+
|
711
|
+
<div class="method_details ">
|
712
|
+
<h3 class="signature " id="current_tenant_id-class_method">
|
713
|
+
|
714
|
+
.<strong>current_tenant_id</strong> ⇒ <tt>Object</tt>
|
715
|
+
|
716
|
+
|
717
|
+
|
718
|
+
|
719
|
+
|
720
|
+
</h3><table class="source_code">
|
721
|
+
<tr>
|
722
|
+
<td>
|
723
|
+
<pre class="lines">
|
724
|
+
|
725
|
+
|
726
|
+
75
|
727
|
+
76
|
728
|
+
77</pre>
|
729
|
+
</td>
|
730
|
+
<td>
|
731
|
+
<pre class="code"><span class="info file"># File 'lib/activerecord-multi-tenant/multi_tenant.rb', line 75</span>
|
732
|
+
|
733
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_current_tenant_id'>current_tenant_id</span>
|
734
|
+
<span class='id identifier rubyid_current_tenant_is_id?'>current_tenant_is_id?</span> <span class='op'>?</span> <span class='id identifier rubyid_current_tenant'>current_tenant</span> <span class='op'>:</span> <span class='id identifier rubyid_current_tenant'>current_tenant</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:id</span><span class='rparen'>)</span>
|
735
|
+
<span class='kw'>end</span></pre>
|
736
|
+
</td>
|
737
|
+
</tr>
|
738
|
+
</table>
|
739
|
+
</div>
|
740
|
+
|
741
|
+
<div class="method_details ">
|
742
|
+
<h3 class="signature " id="current_tenant_is_id?-class_method">
|
743
|
+
|
744
|
+
.<strong>current_tenant_is_id?</strong> ⇒ <tt>Boolean</tt>
|
745
|
+
|
746
|
+
|
747
|
+
|
748
|
+
|
749
|
+
|
750
|
+
</h3><div class="docstring">
|
751
|
+
<div class="discussion">
|
752
|
+
|
753
|
+
|
754
|
+
</div>
|
755
|
+
</div>
|
756
|
+
<div class="tags">
|
757
|
+
|
758
|
+
<p class="tag_title">Returns:</p>
|
759
|
+
<ul class="return">
|
760
|
+
|
761
|
+
<li>
|
762
|
+
|
763
|
+
|
764
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
765
|
+
|
766
|
+
|
767
|
+
|
768
|
+
</li>
|
769
|
+
|
770
|
+
</ul>
|
771
|
+
|
772
|
+
</div><table class="source_code">
|
773
|
+
<tr>
|
774
|
+
<td>
|
775
|
+
<pre class="lines">
|
776
|
+
|
777
|
+
|
778
|
+
79
|
779
|
+
80
|
780
|
+
81</pre>
|
781
|
+
</td>
|
782
|
+
<td>
|
783
|
+
<pre class="code"><span class="info file"># File 'lib/activerecord-multi-tenant/multi_tenant.rb', line 79</span>
|
784
|
+
|
785
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_current_tenant_is_id?'>current_tenant_is_id?</span>
|
786
|
+
<span class='id identifier rubyid_current_tenant'>current_tenant</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>String</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='id identifier rubyid_current_tenant'>current_tenant</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Integer</span><span class='rparen'>)</span>
|
787
|
+
<span class='kw'>end</span></pre>
|
788
|
+
</td>
|
789
|
+
</tr>
|
790
|
+
</table>
|
791
|
+
</div>
|
792
|
+
|
793
|
+
<div class="method_details ">
|
794
|
+
<h3 class="signature " id="default_tenant_class-class_method">
|
795
|
+
|
796
|
+
.<strong>default_tenant_class</strong> ⇒ <tt>Object</tt>
|
797
|
+
|
798
|
+
|
799
|
+
|
800
|
+
|
801
|
+
|
802
|
+
</h3><table class="source_code">
|
803
|
+
<tr>
|
804
|
+
<td>
|
805
|
+
<pre class="lines">
|
806
|
+
|
807
|
+
|
808
|
+
22
|
809
|
+
23
|
810
|
+
24</pre>
|
811
|
+
</td>
|
812
|
+
<td>
|
813
|
+
<pre class="code"><span class="info file"># File 'lib/activerecord-multi-tenant/multi_tenant.rb', line 22</span>
|
814
|
+
|
815
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_default_tenant_class'>default_tenant_class</span>
|
816
|
+
<span class='cvar'>@@default_tenant_class</span> <span class='op'>||=</span> <span class='kw'>nil</span>
|
817
|
+
<span class='kw'>end</span></pre>
|
818
|
+
</td>
|
819
|
+
</tr>
|
820
|
+
</table>
|
821
|
+
</div>
|
822
|
+
|
823
|
+
<div class="method_details ">
|
824
|
+
<h3 class="signature " id="default_tenant_class=-class_method">
|
825
|
+
|
826
|
+
.<strong>default_tenant_class=</strong>(tenant_class) ⇒ <tt>Object</tt>
|
827
|
+
|
828
|
+
|
829
|
+
|
830
|
+
|
831
|
+
|
832
|
+
</h3><div class="docstring">
|
833
|
+
<div class="discussion">
|
834
|
+
|
835
|
+
<p>rubocop:disable Style/ClassVars In some cases we only have an ID - if defined we’ll return the default tenant class in such cases</p>
|
836
|
+
|
837
|
+
|
838
|
+
</div>
|
839
|
+
</div>
|
840
|
+
<div class="tags">
|
841
|
+
|
842
|
+
|
843
|
+
</div><table class="source_code">
|
844
|
+
<tr>
|
845
|
+
<td>
|
846
|
+
<pre class="lines">
|
847
|
+
|
848
|
+
|
849
|
+
18
|
850
|
+
19
|
851
|
+
20</pre>
|
852
|
+
</td>
|
853
|
+
<td>
|
854
|
+
<pre class="code"><span class="info file"># File 'lib/activerecord-multi-tenant/multi_tenant.rb', line 18</span>
|
855
|
+
|
856
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_default_tenant_class='>default_tenant_class=</span><span class='lparen'>(</span><span class='id identifier rubyid_tenant_class'>tenant_class</span><span class='rparen'>)</span>
|
857
|
+
<span class='cvar'>@@default_tenant_class</span> <span class='op'>=</span> <span class='id identifier rubyid_tenant_class'>tenant_class</span>
|
858
|
+
<span class='kw'>end</span></pre>
|
859
|
+
</td>
|
860
|
+
</tr>
|
861
|
+
</table>
|
862
|
+
</div>
|
863
|
+
|
864
|
+
<div class="method_details ">
|
865
|
+
<h3 class="signature " id="enable_query_monitor-class_method">
|
866
|
+
|
867
|
+
.<strong>enable_query_monitor</strong> ⇒ <tt>Object</tt>
|
868
|
+
|
869
|
+
|
870
|
+
|
871
|
+
|
872
|
+
|
873
|
+
</h3><table class="source_code">
|
874
|
+
<tr>
|
875
|
+
<td>
|
876
|
+
<pre class="lines">
|
877
|
+
|
878
|
+
|
879
|
+
10
|
880
|
+
11
|
881
|
+
12</pre>
|
882
|
+
</td>
|
883
|
+
<td>
|
884
|
+
<pre class="code"><span class="info file"># File 'lib/activerecord-multi-tenant/query_monitor.rb', line 10</span>
|
885
|
+
|
886
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_enable_query_monitor'>enable_query_monitor</span>
|
887
|
+
<span class='cvar'>@@enable_query_monitor</span> <span class='op'>=</span> <span class='kw'>true</span>
|
888
|
+
<span class='kw'>end</span></pre>
|
889
|
+
</td>
|
890
|
+
</tr>
|
891
|
+
</table>
|
892
|
+
</div>
|
893
|
+
|
894
|
+
<div class="method_details ">
|
895
|
+
<h3 class="signature " id="enable_write_only_mode-class_method">
|
896
|
+
|
897
|
+
.<strong>enable_write_only_mode</strong> ⇒ <tt>Object</tt>
|
898
|
+
|
899
|
+
|
900
|
+
|
901
|
+
|
902
|
+
|
903
|
+
</h3><div class="docstring">
|
904
|
+
<div class="discussion">
|
905
|
+
|
906
|
+
<p>Write-only Mode - this only adds the tenant_id to new records, but doesn’t require its presence for SELECTs/UPDATEs/DELETEs</p>
|
907
|
+
|
908
|
+
|
909
|
+
</div>
|
910
|
+
</div>
|
911
|
+
<div class="tags">
|
912
|
+
|
913
|
+
|
914
|
+
</div><table class="source_code">
|
915
|
+
<tr>
|
916
|
+
<td>
|
917
|
+
<pre class="lines">
|
918
|
+
|
919
|
+
|
920
|
+
28
|
921
|
+
29
|
922
|
+
30</pre>
|
923
|
+
</td>
|
924
|
+
<td>
|
925
|
+
<pre class="code"><span class="info file"># File 'lib/activerecord-multi-tenant/multi_tenant.rb', line 28</span>
|
926
|
+
|
927
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_enable_write_only_mode'>enable_write_only_mode</span>
|
928
|
+
<span class='cvar'>@@enable_write_only_mode</span> <span class='op'>=</span> <span class='kw'>true</span>
|
929
|
+
<span class='kw'>end</span></pre>
|
930
|
+
</td>
|
931
|
+
</tr>
|
932
|
+
</table>
|
933
|
+
</div>
|
934
|
+
|
935
|
+
<div class="method_details ">
|
936
|
+
<h3 class="signature " id="load_current_tenant!-class_method">
|
937
|
+
|
938
|
+
.<strong>load_current_tenant!</strong> ⇒ <tt>Object</tt>
|
939
|
+
|
940
|
+
|
941
|
+
|
942
|
+
|
943
|
+
|
944
|
+
</h3><table class="source_code">
|
945
|
+
<tr>
|
946
|
+
<td>
|
947
|
+
<pre class="lines">
|
948
|
+
|
949
|
+
|
950
|
+
91
|
951
|
+
92
|
952
|
+
93
|
953
|
+
94
|
954
|
+
95
|
955
|
+
96
|
956
|
+
97</pre>
|
957
|
+
</td>
|
958
|
+
<td>
|
959
|
+
<pre class="code"><span class="info file"># File 'lib/activerecord-multi-tenant/multi_tenant.rb', line 91</span>
|
960
|
+
|
961
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_load_current_tenant!'>load_current_tenant!</span>
|
962
|
+
<span class='kw'>return</span> <span class='const'><span class='object_link'><a href="" title="MultiTenant (module)">MultiTenant</a></span></span><span class='period'>.</span><span class='id identifier rubyid_current_tenant'><span class='object_link'><a href="#current_tenant-class_method" title="MultiTenant.current_tenant (method)">current_tenant</a></span></span> <span class='kw'>if</span> <span class='const'><span class='object_link'><a href="" title="MultiTenant (module)">MultiTenant</a></span></span><span class='period'>.</span><span class='id identifier rubyid_current_tenant'><span class='object_link'><a href="#current_tenant-class_method" title="MultiTenant.current_tenant (method)">current_tenant</a></span></span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_current_tenant_is_id?'>current_tenant_is_id?</span>
|
963
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>MultiTenant.current_tenant must be set to load</span><span class='tstring_end'>'</span></span> <span class='kw'>if</span> <span class='const'><span class='object_link'><a href="" title="MultiTenant (module)">MultiTenant</a></span></span><span class='period'>.</span><span class='id identifier rubyid_current_tenant'><span class='object_link'><a href="#current_tenant-class_method" title="MultiTenant.current_tenant (method)">current_tenant</a></span></span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
964
|
+
|
965
|
+
<span class='id identifier rubyid_klass'>klass</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="" title="MultiTenant (module)">MultiTenant</a></span></span><span class='period'>.</span><span class='id identifier rubyid_default_tenant_class'><span class='object_link'><a href="#default_tenant_class-class_method" title="MultiTenant.default_tenant_class (method)">default_tenant_class</a></span></span> <span class='op'>||</span> <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Only have tenant id, and no default tenant class set</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
966
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_current_tenant'>current_tenant</span> <span class='op'>=</span> <span class='id identifier rubyid_klass'>klass</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="" title="MultiTenant (module)">MultiTenant</a></span></span><span class='period'>.</span><span class='id identifier rubyid_current_tenant_id'><span class='object_link'><a href="#current_tenant_id-class_method" title="MultiTenant.current_tenant_id (method)">current_tenant_id</a></span></span><span class='rparen'>)</span>
|
967
|
+
<span class='kw'>end</span></pre>
|
968
|
+
</td>
|
969
|
+
</tr>
|
970
|
+
</table>
|
971
|
+
</div>
|
972
|
+
|
973
|
+
<div class="method_details ">
|
974
|
+
<h3 class="signature " id="multi_tenant_model_for_arel-class_method">
|
975
|
+
|
976
|
+
.<strong>multi_tenant_model_for_arel</strong>(arel) ⇒ <tt>Object</tt>
|
977
|
+
|
978
|
+
|
979
|
+
|
980
|
+
|
981
|
+
|
982
|
+
</h3><table class="source_code">
|
983
|
+
<tr>
|
984
|
+
<td>
|
985
|
+
<pre class="lines">
|
986
|
+
|
987
|
+
|
988
|
+
57
|
989
|
+
58
|
990
|
+
59
|
991
|
+
60
|
992
|
+
61
|
993
|
+
62
|
994
|
+
63
|
995
|
+
64
|
996
|
+
65</pre>
|
997
|
+
</td>
|
998
|
+
<td>
|
999
|
+
<pre class="code"><span class="info file"># File 'lib/activerecord-multi-tenant/multi_tenant.rb', line 57</span>
|
1000
|
+
|
1001
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_multi_tenant_model_for_arel'>multi_tenant_model_for_arel</span><span class='lparen'>(</span><span class='id identifier rubyid_arel'>arel</span><span class='rparen'>)</span>
|
1002
|
+
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='id identifier rubyid_arel'>arel</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:ast</span><span class='rparen'>)</span>
|
1003
|
+
|
1004
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_arel'>arel</span><span class='period'>.</span><span class='id identifier rubyid_ast'>ast</span><span class='period'>.</span><span class='id identifier rubyid_relation'>relation</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>Arel</span><span class='op'>::</span><span class='const'>Nodes</span><span class='op'>::</span><span class='const'>JoinSource</span>
|
1005
|
+
<span class='const'><span class='object_link'><a href="" title="MultiTenant (module)">MultiTenant</a></span></span><span class='period'>.</span><span class='id identifier rubyid_multi_tenant_model_for_table'><span class='object_link'><a href="#multi_tenant_model_for_table-class_method" title="MultiTenant.multi_tenant_model_for_table (method)">multi_tenant_model_for_table</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_arel'>arel</span><span class='period'>.</span><span class='id identifier rubyid_ast'>ast</span><span class='period'>.</span><span class='id identifier rubyid_relation'>relation</span><span class='period'>.</span><span class='id identifier rubyid_left'>left</span><span class='period'>.</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rparen'>)</span>
|
1006
|
+
<span class='kw'>else</span>
|
1007
|
+
<span class='const'><span class='object_link'><a href="" title="MultiTenant (module)">MultiTenant</a></span></span><span class='period'>.</span><span class='id identifier rubyid_multi_tenant_model_for_table'><span class='object_link'><a href="#multi_tenant_model_for_table-class_method" title="MultiTenant.multi_tenant_model_for_table (method)">multi_tenant_model_for_table</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_arel'>arel</span><span class='period'>.</span><span class='id identifier rubyid_ast'>ast</span><span class='period'>.</span><span class='id identifier rubyid_relation'>relation</span><span class='period'>.</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rparen'>)</span>
|
1008
|
+
<span class='kw'>end</span>
|
1009
|
+
<span class='kw'>end</span></pre>
|
1010
|
+
</td>
|
1011
|
+
</tr>
|
1012
|
+
</table>
|
1013
|
+
</div>
|
1014
|
+
|
1015
|
+
<div class="method_details ">
|
1016
|
+
<h3 class="signature " id="multi_tenant_model_for_table-class_method">
|
1017
|
+
|
1018
|
+
.<strong>multi_tenant_model_for_table</strong>(table_name) ⇒ <tt>Object</tt>
|
1019
|
+
|
1020
|
+
|
1021
|
+
|
1022
|
+
|
1023
|
+
|
1024
|
+
</h3><table class="source_code">
|
1025
|
+
<tr>
|
1026
|
+
<td>
|
1027
|
+
<pre class="lines">
|
1028
|
+
|
1029
|
+
|
1030
|
+
44
|
1031
|
+
45
|
1032
|
+
46
|
1033
|
+
47
|
1034
|
+
48
|
1035
|
+
49
|
1036
|
+
50
|
1037
|
+
51
|
1038
|
+
52
|
1039
|
+
53
|
1040
|
+
54
|
1041
|
+
55</pre>
|
1042
|
+
</td>
|
1043
|
+
<td>
|
1044
|
+
<pre class="code"><span class="info file"># File 'lib/activerecord-multi-tenant/multi_tenant.rb', line 44</span>
|
1045
|
+
|
1046
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_multi_tenant_model_for_table'>multi_tenant_model_for_table</span><span class='lparen'>(</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rparen'>)</span>
|
1047
|
+
<span class='cvar'>@@multi_tenant_models</span> <span class='op'>||=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
1048
|
+
|
1049
|
+
<span class='kw'>unless</span> <span class='kw'>defined?</span><span class='lparen'>(</span><span class='cvar'>@@multi_tenant_model_table_names</span><span class='rparen'>)</span>
|
1050
|
+
<span class='cvar'>@@multi_tenant_model_table_names</span> <span class='op'>=</span> <span class='cvar'>@@multi_tenant_models</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_model'>model</span><span class='op'>|</span>
|
1051
|
+
<span class='lbracket'>[</span><span class='id identifier rubyid_model'>model</span><span class='period'>.</span><span class='id identifier rubyid_table_name'>table_name</span><span class='comma'>,</span> <span class='id identifier rubyid_model'>model</span><span class='rbracket'>]</span> <span class='kw'>if</span> <span class='id identifier rubyid_model'>model</span><span class='period'>.</span><span class='id identifier rubyid_table_name'>table_name</span>
|
1052
|
+
<span class='kw'>end</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span><span class='period'>.</span><span class='id identifier rubyid_to_h'>to_h</span>
|
1053
|
+
<span class='kw'>end</span>
|
1054
|
+
|
1055
|
+
<span class='cvar'>@@multi_tenant_model_table_names</span><span class='lbracket'>[</span><span class='id identifier rubyid_table_name'>table_name</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rbracket'>]</span>
|
1056
|
+
<span class='comment'># rubocop:enable Style/ClassVars
|
1057
|
+
</span><span class='kw'>end</span></pre>
|
1058
|
+
</td>
|
1059
|
+
</tr>
|
1060
|
+
</table>
|
1061
|
+
</div>
|
1062
|
+
|
1063
|
+
<div class="method_details ">
|
1064
|
+
<h3 class="signature " id="partition_key-class_method">
|
1065
|
+
|
1066
|
+
.<strong>partition_key</strong>(tenant_name) ⇒ <tt>Object</tt>
|
1067
|
+
|
1068
|
+
|
1069
|
+
|
1070
|
+
|
1071
|
+
|
1072
|
+
</h3><table class="source_code">
|
1073
|
+
<tr>
|
1074
|
+
<td>
|
1075
|
+
<pre class="lines">
|
1076
|
+
|
1077
|
+
|
1078
|
+
12
|
1079
|
+
13
|
1080
|
+
14</pre>
|
1081
|
+
</td>
|
1082
|
+
<td>
|
1083
|
+
<pre class="code"><span class="info file"># File 'lib/activerecord-multi-tenant/multi_tenant.rb', line 12</span>
|
1084
|
+
|
1085
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_partition_key'>partition_key</span><span class='lparen'>(</span><span class='id identifier rubyid_tenant_name'>tenant_name</span><span class='rparen'>)</span>
|
1086
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_tenant_name'>tenant_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>_id</span><span class='tstring_end'>"</span></span>
|
1087
|
+
<span class='kw'>end</span></pre>
|
1088
|
+
</td>
|
1089
|
+
</tr>
|
1090
|
+
</table>
|
1091
|
+
</div>
|
1092
|
+
|
1093
|
+
<div class="method_details ">
|
1094
|
+
<h3 class="signature " id="query_monitor_enabled?-class_method">
|
1095
|
+
|
1096
|
+
.<strong>query_monitor_enabled?</strong> ⇒ <tt>Boolean</tt>
|
1097
|
+
|
1098
|
+
|
1099
|
+
|
1100
|
+
|
1101
|
+
|
1102
|
+
</h3><div class="docstring">
|
1103
|
+
<div class="discussion">
|
1104
|
+
|
1105
|
+
|
1106
|
+
</div>
|
1107
|
+
</div>
|
1108
|
+
<div class="tags">
|
1109
|
+
|
1110
|
+
<p class="tag_title">Returns:</p>
|
1111
|
+
<ul class="return">
|
1112
|
+
|
1113
|
+
<li>
|
1114
|
+
|
1115
|
+
|
1116
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
1117
|
+
|
1118
|
+
|
1119
|
+
|
1120
|
+
</li>
|
1121
|
+
|
1122
|
+
</ul>
|
1123
|
+
|
1124
|
+
</div><table class="source_code">
|
1125
|
+
<tr>
|
1126
|
+
<td>
|
1127
|
+
<pre class="lines">
|
1128
|
+
|
1129
|
+
|
1130
|
+
14
|
1131
|
+
15
|
1132
|
+
16</pre>
|
1133
|
+
</td>
|
1134
|
+
<td>
|
1135
|
+
<pre class="code"><span class="info file"># File 'lib/activerecord-multi-tenant/query_monitor.rb', line 14</span>
|
1136
|
+
|
1137
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_query_monitor_enabled?'>query_monitor_enabled?</span>
|
1138
|
+
<span class='cvar'>@@enable_query_monitor</span>
|
1139
|
+
<span class='kw'>end</span></pre>
|
1140
|
+
</td>
|
1141
|
+
</tr>
|
1142
|
+
</table>
|
1143
|
+
</div>
|
1144
|
+
|
1145
|
+
<div class="method_details ">
|
1146
|
+
<h3 class="signature " id="register_multi_tenant_model-class_method">
|
1147
|
+
|
1148
|
+
.<strong>register_multi_tenant_model</strong>(model_klass) ⇒ <tt>Object</tt>
|
1149
|
+
|
1150
|
+
|
1151
|
+
|
1152
|
+
|
1153
|
+
|
1154
|
+
</h3><div class="docstring">
|
1155
|
+
<div class="discussion">
|
1156
|
+
|
1157
|
+
<p>Registry that maps table names to models (used by the query rewriter)</p>
|
1158
|
+
|
1159
|
+
|
1160
|
+
</div>
|
1161
|
+
</div>
|
1162
|
+
<div class="tags">
|
1163
|
+
|
1164
|
+
|
1165
|
+
</div><table class="source_code">
|
1166
|
+
<tr>
|
1167
|
+
<td>
|
1168
|
+
<pre class="lines">
|
1169
|
+
|
1170
|
+
|
1171
|
+
37
|
1172
|
+
38
|
1173
|
+
39
|
1174
|
+
40
|
1175
|
+
41
|
1176
|
+
42</pre>
|
1177
|
+
</td>
|
1178
|
+
<td>
|
1179
|
+
<pre class="code"><span class="info file"># File 'lib/activerecord-multi-tenant/multi_tenant.rb', line 37</span>
|
1180
|
+
|
1181
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_register_multi_tenant_model'>register_multi_tenant_model</span><span class='lparen'>(</span><span class='id identifier rubyid_model_klass'>model_klass</span><span class='rparen'>)</span>
|
1182
|
+
<span class='cvar'>@@multi_tenant_models</span> <span class='op'>||=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
1183
|
+
<span class='cvar'>@@multi_tenant_models</span><span class='period'>.</span><span class='id identifier rubyid_push'>push</span><span class='lparen'>(</span><span class='id identifier rubyid_model_klass'>model_klass</span><span class='rparen'>)</span>
|
1184
|
+
|
1185
|
+
<span class='id identifier rubyid_remove_class_variable'>remove_class_variable</span><span class='lparen'>(</span><span class='symbol'>:@@multi_tenant_model_table_names</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='kw'>defined?</span><span class='lparen'>(</span><span class='cvar'>@@multi_tenant_model_table_names</span><span class='rparen'>)</span>
|
1186
|
+
<span class='kw'>end</span></pre>
|
1187
|
+
</td>
|
1188
|
+
</tr>
|
1189
|
+
</table>
|
1190
|
+
</div>
|
1191
|
+
|
1192
|
+
<div class="method_details ">
|
1193
|
+
<h3 class="signature " id="tenant_klass_defined?-class_method">
|
1194
|
+
|
1195
|
+
.<strong>tenant_klass_defined?</strong>(tenant_name) ⇒ <tt>Boolean</tt>
|
1196
|
+
|
1197
|
+
|
1198
|
+
|
1199
|
+
|
1200
|
+
|
1201
|
+
</h3><div class="docstring">
|
1202
|
+
<div class="discussion">
|
1203
|
+
|
1204
|
+
|
1205
|
+
</div>
|
1206
|
+
</div>
|
1207
|
+
<div class="tags">
|
1208
|
+
|
1209
|
+
<p class="tag_title">Returns:</p>
|
1210
|
+
<ul class="return">
|
1211
|
+
|
1212
|
+
<li>
|
1213
|
+
|
1214
|
+
|
1215
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
1216
|
+
|
1217
|
+
|
1218
|
+
|
1219
|
+
</li>
|
1220
|
+
|
1221
|
+
</ul>
|
1222
|
+
|
1223
|
+
</div><table class="source_code">
|
1224
|
+
<tr>
|
1225
|
+
<td>
|
1226
|
+
<pre class="lines">
|
1227
|
+
|
1228
|
+
|
1229
|
+
8
|
1230
|
+
9
|
1231
|
+
10</pre>
|
1232
|
+
</td>
|
1233
|
+
<td>
|
1234
|
+
<pre class="code"><span class="info file"># File 'lib/activerecord-multi-tenant/multi_tenant.rb', line 8</span>
|
1235
|
+
|
1236
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_tenant_klass_defined?'>tenant_klass_defined?</span><span class='lparen'>(</span><span class='id identifier rubyid_tenant_name'>tenant_name</span><span class='rparen'>)</span>
|
1237
|
+
<span class='op'>!</span><span class='op'>!</span><span class='id identifier rubyid_tenant_name'>tenant_name</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_classify'>classify</span><span class='period'>.</span><span class='id identifier rubyid_safe_constantize'>safe_constantize</span>
|
1238
|
+
<span class='kw'>end</span></pre>
|
1239
|
+
</td>
|
1240
|
+
</tr>
|
1241
|
+
</table>
|
1242
|
+
</div>
|
1243
|
+
|
1244
|
+
<div class="method_details ">
|
1245
|
+
<h3 class="signature " id="with-class_method">
|
1246
|
+
|
1247
|
+
.<strong>with</strong>(tenant, &block) ⇒ <tt>Object</tt>
|
1248
|
+
|
1249
|
+
|
1250
|
+
|
1251
|
+
|
1252
|
+
|
1253
|
+
</h3><table class="source_code">
|
1254
|
+
<tr>
|
1255
|
+
<td>
|
1256
|
+
<pre class="lines">
|
1257
|
+
|
1258
|
+
|
1259
|
+
99
|
1260
|
+
100
|
1261
|
+
101
|
1262
|
+
102
|
1263
|
+
103
|
1264
|
+
104
|
1265
|
+
105
|
1266
|
+
106
|
1267
|
+
107
|
1268
|
+
108
|
1269
|
+
109</pre>
|
1270
|
+
</td>
|
1271
|
+
<td>
|
1272
|
+
<pre class="code"><span class="info file"># File 'lib/activerecord-multi-tenant/multi_tenant.rb', line 99</span>
|
1273
|
+
|
1274
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_tenant'>tenant</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
1275
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_block'>block</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span> <span class='kw'>if</span> <span class='id identifier rubyid_current_tenant'>current_tenant</span> <span class='op'>==</span> <span class='id identifier rubyid_tenant'>tenant</span>
|
1276
|
+
|
1277
|
+
<span class='id identifier rubyid_old_tenant'>old_tenant</span> <span class='op'>=</span> <span class='id identifier rubyid_current_tenant'>current_tenant</span>
|
1278
|
+
<span class='kw'>begin</span>
|
1279
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_current_tenant'>current_tenant</span> <span class='op'>=</span> <span class='id identifier rubyid_tenant'>tenant</span>
|
1280
|
+
<span class='id identifier rubyid_block'>block</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span>
|
1281
|
+
<span class='kw'>ensure</span>
|
1282
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_current_tenant'>current_tenant</span> <span class='op'>=</span> <span class='id identifier rubyid_old_tenant'>old_tenant</span>
|
1283
|
+
<span class='kw'>end</span>
|
1284
|
+
<span class='kw'>end</span></pre>
|
1285
|
+
</td>
|
1286
|
+
</tr>
|
1287
|
+
</table>
|
1288
|
+
</div>
|
1289
|
+
|
1290
|
+
<div class="method_details ">
|
1291
|
+
<h3 class="signature " id="with_write_only_mode_enabled?-class_method">
|
1292
|
+
|
1293
|
+
.<strong>with_write_only_mode_enabled?</strong> ⇒ <tt>Boolean</tt>
|
1294
|
+
|
1295
|
+
|
1296
|
+
|
1297
|
+
|
1298
|
+
|
1299
|
+
</h3><div class="docstring">
|
1300
|
+
<div class="discussion">
|
1301
|
+
|
1302
|
+
|
1303
|
+
</div>
|
1304
|
+
</div>
|
1305
|
+
<div class="tags">
|
1306
|
+
|
1307
|
+
<p class="tag_title">Returns:</p>
|
1308
|
+
<ul class="return">
|
1309
|
+
|
1310
|
+
<li>
|
1311
|
+
|
1312
|
+
|
1313
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
1314
|
+
|
1315
|
+
|
1316
|
+
|
1317
|
+
</li>
|
1318
|
+
|
1319
|
+
</ul>
|
1320
|
+
|
1321
|
+
</div><table class="source_code">
|
1322
|
+
<tr>
|
1323
|
+
<td>
|
1324
|
+
<pre class="lines">
|
1325
|
+
|
1326
|
+
|
1327
|
+
32
|
1328
|
+
33
|
1329
|
+
34</pre>
|
1330
|
+
</td>
|
1331
|
+
<td>
|
1332
|
+
<pre class="code"><span class="info file"># File 'lib/activerecord-multi-tenant/multi_tenant.rb', line 32</span>
|
1333
|
+
|
1334
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_with_write_only_mode_enabled?'>with_write_only_mode_enabled?</span>
|
1335
|
+
<span class='cvar'>@@enable_write_only_mode</span> <span class='op'>||=</span> <span class='kw'>false</span>
|
1336
|
+
<span class='kw'>end</span></pre>
|
1337
|
+
</td>
|
1338
|
+
</tr>
|
1339
|
+
</table>
|
1340
|
+
</div>
|
1341
|
+
|
1342
|
+
<div class="method_details ">
|
1343
|
+
<h3 class="signature " id="without-class_method">
|
1344
|
+
|
1345
|
+
.<strong>without</strong>(&block) ⇒ <tt>Object</tt>
|
1346
|
+
|
1347
|
+
|
1348
|
+
|
1349
|
+
|
1350
|
+
|
1351
|
+
</h3><table class="source_code">
|
1352
|
+
<tr>
|
1353
|
+
<td>
|
1354
|
+
<pre class="lines">
|
1355
|
+
|
1356
|
+
|
1357
|
+
111
|
1358
|
+
112
|
1359
|
+
113
|
1360
|
+
114
|
1361
|
+
115
|
1362
|
+
116
|
1363
|
+
117
|
1364
|
+
118
|
1365
|
+
119
|
1366
|
+
120
|
1367
|
+
121</pre>
|
1368
|
+
</td>
|
1369
|
+
<td>
|
1370
|
+
<pre class="code"><span class="info file"># File 'lib/activerecord-multi-tenant/multi_tenant.rb', line 111</span>
|
1371
|
+
|
1372
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_without'>without</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
1373
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_block'>block</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span> <span class='kw'>if</span> <span class='id identifier rubyid_current_tenant'>current_tenant</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
1374
|
+
|
1375
|
+
<span class='id identifier rubyid_old_tenant'>old_tenant</span> <span class='op'>=</span> <span class='id identifier rubyid_current_tenant'>current_tenant</span>
|
1376
|
+
<span class='kw'>begin</span>
|
1377
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_current_tenant'>current_tenant</span> <span class='op'>=</span> <span class='kw'>nil</span>
|
1378
|
+
<span class='id identifier rubyid_block'>block</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span>
|
1379
|
+
<span class='kw'>ensure</span>
|
1380
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_current_tenant'>current_tenant</span> <span class='op'>=</span> <span class='id identifier rubyid_old_tenant'>old_tenant</span>
|
1381
|
+
<span class='kw'>end</span>
|
1382
|
+
<span class='kw'>end</span></pre>
|
1383
|
+
</td>
|
1384
|
+
</tr>
|
1385
|
+
</table>
|
1386
|
+
</div>
|
1387
|
+
|
1388
|
+
<div class="method_details ">
|
1389
|
+
<h3 class="signature " id="wrap_methods-class_method">
|
1390
|
+
|
1391
|
+
.<strong>wrap_methods</strong>(klass, owner, *method_names) ⇒ <tt>Object</tt>
|
1392
|
+
|
1393
|
+
|
1394
|
+
|
1395
|
+
|
1396
|
+
|
1397
|
+
</h3><table class="source_code">
|
1398
|
+
<tr>
|
1399
|
+
<td>
|
1400
|
+
<pre class="lines">
|
1401
|
+
|
1402
|
+
|
1403
|
+
129
|
1404
|
+
130
|
1405
|
+
131
|
1406
|
+
132
|
1407
|
+
133
|
1408
|
+
134
|
1409
|
+
135
|
1410
|
+
136
|
1411
|
+
137
|
1412
|
+
138
|
1413
|
+
139
|
1414
|
+
140
|
1415
|
+
141
|
1416
|
+
142
|
1417
|
+
143</pre>
|
1418
|
+
</td>
|
1419
|
+
<td>
|
1420
|
+
<pre class="code"><span class="info file"># File 'lib/activerecord-multi-tenant/multi_tenant.rb', line 129</span>
|
1421
|
+
|
1422
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_wrap_methods'>wrap_methods</span><span class='lparen'>(</span><span class='id identifier rubyid_klass'>klass</span><span class='comma'>,</span> <span class='id identifier rubyid_owner'>owner</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_method_names'>method_names</span><span class='rparen'>)</span>
|
1423
|
+
<span class='id identifier rubyid_method_names'>method_names</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_method_name'>method_name</span><span class='op'>|</span>
|
1424
|
+
<span class='id identifier rubyid_original_method_name'>original_method_name</span> <span class='op'>=</span> <span class='symbol'>:"_mt_original_</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_method_name'>method_name</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span>
|
1425
|
+
<span class='id identifier rubyid_klass'>klass</span><span class='period'>.</span><span class='id identifier rubyid_class_eval'>class_eval</span> <span class='heredoc_beg'><<-CODE</span><span class='comma'>,</span> <span class='kw'>__FILE__</span><span class='comma'>,</span> <span class='kw'>__LINE__</span> <span class='op'>+</span> <span class='int'>1</span>
|
1426
|
+
<span class='tstring_content'> alias_method :</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_original_method_name'>original_method_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>, :</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_method_name'>method_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>
|
1427
|
+
def </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_method_name'>method_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>(*args, &block)
|
1428
|
+
if MultiTenant.multi_tenant_model_for_table(</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_owner'>owner</span><span class='embexpr_end'>}</span><span class='tstring_content'>.class.table_name).present? && </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_owner'>owner</span><span class='embexpr_end'>}</span><span class='tstring_content'>.persisted? && MultiTenant.current_tenant_id.nil? && </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_owner'>owner</span><span class='embexpr_end'>}</span><span class='tstring_content'>.class.respond_to?(:partition_key) && </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_owner'>owner</span><span class='embexpr_end'>}</span><span class='tstring_content'>.attributes.include?(</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_owner'>owner</span><span class='embexpr_end'>}</span><span class='tstring_content'>.class.partition_key)
|
1429
|
+
MultiTenant.with(</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_owner'>owner</span><span class='embexpr_end'>}</span><span class='tstring_content'>.public_send(</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_owner'>owner</span><span class='embexpr_end'>}</span><span class='tstring_content'>.class.partition_key)) { </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_original_method_name'>original_method_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>(*args, &block) }
|
1430
|
+
else
|
1431
|
+
</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_original_method_name'>original_method_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>(*args, &block)
|
1432
|
+
end
|
1433
|
+
end
|
1434
|
+
</span><span class='heredoc_end'> CODE
|
1435
|
+
</span> <span class='kw'>end</span>
|
1436
|
+
<span class='kw'>end</span></pre>
|
1437
|
+
</td>
|
1438
|
+
</tr>
|
1439
|
+
</table>
|
1440
|
+
</div>
|
1441
|
+
|
1442
|
+
</div>
|
1443
|
+
|
1444
|
+
</div>
|
1445
|
+
|
1446
|
+
<div id="footer">
|
1447
|
+
Generated on Sat May 27 10:16:24 2023 by
|
1448
|
+
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1449
|
+
0.9.34 (ruby-3.2.2).
|
1450
|
+
</div>
|
1451
|
+
|
1452
|
+
</div>
|
1453
|
+
</body>
|
1454
|
+
</html>
|