activerecord-multi-tenant 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/active-record-multi-tenant-tests.yml +80 -0
  3. data/.gitignore +6 -0
  4. data/.readthedocs.yaml +15 -0
  5. data/.rspec +0 -0
  6. data/.rubocop.yml +51 -0
  7. data/Appraisals +0 -0
  8. data/CHANGELOG.md +6 -0
  9. data/Gemfile +3 -1
  10. data/LICENSE +0 -0
  11. data/README.md +2 -1
  12. data/Rakefile +1 -1
  13. data/activerecord-multi-tenant.gemspec +28 -22
  14. data/docker-compose.yml +24 -18
  15. data/docs/.gitignore +3 -0
  16. data/docs/Makefile +28 -0
  17. data/docs/api-reference.sh +10 -0
  18. data/docs/requirements.in +4 -0
  19. data/docs/requirements.txt +62 -0
  20. data/docs/source/_static/api-reference/ActiveRecord/Associations/Association.html +285 -0
  21. data/docs/source/_static/api-reference/ActiveRecord/Associations/ClassMethods.html +255 -0
  22. data/docs/source/_static/api-reference/ActiveRecord/Associations.html +117 -0
  23. data/docs/source/_static/api-reference/ActiveRecord/ConnectionAdapters/SchemaStatements.html +232 -0
  24. data/docs/source/_static/api-reference/ActiveRecord/ConnectionAdapters.html +126 -0
  25. data/docs/source/_static/api-reference/ActiveRecord/QueryMethods.html +336 -0
  26. data/docs/source/_static/api-reference/ActiveRecord/SchemaDumper.html +121 -0
  27. data/docs/source/_static/api-reference/ActiveRecord.html +130 -0
  28. data/docs/source/_static/api-reference/MultiTenant/ArelTenantVisitor.html +755 -0
  29. data/docs/source/_static/api-reference/MultiTenant/ArelVisitorsDepthFirst.html +208 -0
  30. data/docs/source/_static/api-reference/MultiTenant/BaseTenantEnforcementClause.html +462 -0
  31. data/docs/source/_static/api-reference/MultiTenant/Context.html +659 -0
  32. data/docs/source/_static/api-reference/MultiTenant/ControllerExtensions.html +202 -0
  33. data/docs/source/_static/api-reference/MultiTenant/CopyFromClient.html +186 -0
  34. data/docs/source/_static/api-reference/MultiTenant/CopyFromClientHelper.html +362 -0
  35. data/docs/source/_static/api-reference/MultiTenant/Current.html +124 -0
  36. data/docs/source/_static/api-reference/MultiTenant/DatabaseStatements.html +366 -0
  37. data/docs/source/_static/api-reference/MultiTenant/FastTruncate.html +226 -0
  38. data/docs/source/_static/api-reference/MultiTenant/MigrationExtensions.html +554 -0
  39. data/docs/source/_static/api-reference/MultiTenant/MissingTenantError.html +124 -0
  40. data/docs/source/_static/api-reference/MultiTenant/ModelExtensionsClassMethods.html +492 -0
  41. data/docs/source/_static/api-reference/MultiTenant/QueryMonitor.html +257 -0
  42. data/docs/source/_static/api-reference/MultiTenant/Table.html +419 -0
  43. data/docs/source/_static/api-reference/MultiTenant/TenantEnforcementClause.html +148 -0
  44. data/docs/source/_static/api-reference/MultiTenant/TenantIsImmutable.html +135 -0
  45. data/docs/source/_static/api-reference/MultiTenant/TenantJoinEnforcementClause.html +310 -0
  46. data/docs/source/_static/api-reference/MultiTenant/TenantValueVisitor.html +239 -0
  47. data/docs/source/_static/api-reference/MultiTenant.html +1454 -0
  48. data/docs/source/_static/api-reference/MultiTenantFindBy.html +180 -0
  49. data/docs/source/_static/api-reference/Sidekiq/Client.html +302 -0
  50. data/docs/source/_static/api-reference/Sidekiq/Middleware/MultiTenant/Client.html +217 -0
  51. data/docs/source/_static/api-reference/Sidekiq/Middleware/MultiTenant/Server.html +219 -0
  52. data/docs/source/_static/api-reference/Sidekiq/Middleware/MultiTenant.html +126 -0
  53. data/docs/source/_static/api-reference/Sidekiq.html +126 -0
  54. data/docs/source/_static/api-reference/_index.html +399 -0
  55. data/docs/source/_static/api-reference/class_list.html +51 -0
  56. data/docs/source/_static/api-reference/css/common.css +1 -0
  57. data/docs/source/_static/api-reference/css/full_list.css +58 -0
  58. data/docs/source/_static/api-reference/css/style.css +497 -0
  59. data/docs/source/_static/api-reference/file.README.html +167 -0
  60. data/docs/source/_static/api-reference/file_list.html +56 -0
  61. data/docs/source/_static/api-reference/frames.html +17 -0
  62. data/docs/source/_static/api-reference/index.html +167 -0
  63. data/docs/source/_static/api-reference/js/app.js +314 -0
  64. data/docs/source/_static/api-reference/js/full_list.js +216 -0
  65. data/docs/source/_static/api-reference/js/jquery.js +4 -0
  66. data/docs/source/_static/api-reference/method_list.html +715 -0
  67. data/docs/source/_static/api-reference/top-level-namespace.html +126 -0
  68. data/docs/source/_templates/.gitignore +4 -0
  69. data/docs/source/api-reference.rst +8 -0
  70. data/docs/source/appendix.rst +26 -0
  71. data/docs/source/changelog.rst +8 -0
  72. data/docs/source/community-and-support.rst +26 -0
  73. data/docs/source/conf.py +30 -0
  74. data/docs/source/contributing.rst +70 -0
  75. data/docs/source/getting-started.rst +37 -0
  76. data/docs/source/guides-and-tutorials.rst +129 -0
  77. data/docs/source/index.rst +54 -0
  78. data/docs/source/introduction.rst +33 -0
  79. data/docs/source/license.rst +22 -0
  80. data/docs/source/troubleshooting.rst +41 -0
  81. data/docs/source/usage-guide.rst +59 -0
  82. data/lib/activerecord-multi-tenant/arel_visitors_depth_first.rb +183 -174
  83. data/lib/activerecord-multi-tenant/controller_extensions.rb +15 -4
  84. data/lib/activerecord-multi-tenant/copy_from_client.rb +4 -0
  85. data/lib/activerecord-multi-tenant/fast_truncate.rb +4 -2
  86. data/lib/activerecord-multi-tenant/habtm.rb +50 -0
  87. data/lib/activerecord-multi-tenant/migrations.rb +18 -8
  88. data/lib/activerecord-multi-tenant/model_extensions.rb +78 -37
  89. data/lib/activerecord-multi-tenant/multi_tenant.rb +40 -21
  90. data/lib/activerecord-multi-tenant/query_monitor.rb +21 -5
  91. data/lib/activerecord-multi-tenant/query_rewriter.rb +111 -80
  92. data/lib/activerecord-multi-tenant/sidekiq.rb +31 -20
  93. data/lib/activerecord-multi-tenant/version.rb +1 -1
  94. data/lib/activerecord-multi-tenant.rb +3 -12
  95. data/lib/activerecord_multi_tenant.rb +12 -0
  96. data/spec/activerecord-multi-tenant/associations_spec.rb +21 -0
  97. data/spec/activerecord-multi-tenant/controller_extensions_spec.rb +3 -2
  98. data/spec/activerecord-multi-tenant/fast_truncate_spec.rb +8 -6
  99. data/spec/activerecord-multi-tenant/model_extensions_spec.rb +233 -153
  100. data/spec/activerecord-multi-tenant/multi_tenant_spec.rb +15 -13
  101. data/spec/activerecord-multi-tenant/query_rewriter_spec.rb +60 -59
  102. data/spec/activerecord-multi-tenant/record_callback_spec.rb +0 -0
  103. data/spec/activerecord-multi-tenant/record_finding_spec.rb +11 -11
  104. data/spec/activerecord-multi-tenant/record_modifications_spec.rb +4 -4
  105. data/spec/activerecord-multi-tenant/sidekiq_spec.rb +10 -10
  106. data/spec/database.yml +0 -0
  107. data/spec/schema.rb +20 -2
  108. data/spec/spec_helper.rb +46 -17
  109. data/spec/support/format_sql.rb +20 -0
  110. metadata +130 -25
  111. data/.github/workflows/CI.yml +0 -47
  112. data/gemfiles/.bundle/config +0 -2
  113. data/gemfiles/active_record_6.0.gemfile +0 -8
  114. data/gemfiles/active_record_6.1.gemfile +0 -8
  115. data/gemfiles/active_record_7.0.gemfile +0 -8
  116. data/gemfiles/rails_6.0.gemfile +0 -8
  117. data/gemfiles/rails_6.1.gemfile +0 -8
  118. data/gemfiles/rails_7.0.gemfile +0 -8
  119. data/lib/activerecord-multi-tenant/with_lock.rb +0 -15
  120. data/spec/activerecord-multi-tenant/schema_dumper_tester.rb +0 -0
@@ -0,0 +1,492 @@
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::ModelExtensionsClassMethods
8
+
9
+ &mdash; 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::ModelExtensionsClassMethods";
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> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../MultiTenant.html" title="MultiTenant (module)">MultiTenant</a></span></span>
41
+ &raquo;
42
+ <span class="title">ModelExtensionsClassMethods</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::ModelExtensionsClassMethods
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/model_extensions.rb</dd>
82
+ </dl>
83
+
84
+ </div>
85
+
86
+ <h2>Overview</h2><div class="docstring">
87
+ <div class="discussion">
88
+
89
+ <p>Extension to the model to allow scoping of models to the current tenant. This is done by adding the multitenant method to the models that need to be scoped. This method is called in the model declaration. Adds scoped_by_tenant? partition_key, primary_key and inherited methods to the model</p>
90
+
91
+
92
+ </div>
93
+ </div>
94
+ <div class="tags">
95
+
96
+
97
+ </div>
98
+
99
+ <h2>
100
+ Constant Summary
101
+ <small><a href="#" class="constants_summary_toggle">collapse</a></small>
102
+ </h2>
103
+
104
+ <dl class="constants">
105
+
106
+ <dt id="DEFAULT_ID_FIELD-constant" class="">DEFAULT_ID_FIELD =
107
+
108
+ </dt>
109
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>id</span><span class='tstring_end'>&#39;</span></span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
110
+
111
+ </dl>
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+ <h2>
122
+ Instance Method Summary
123
+ <small><a href="#" class="summary_toggle">collapse</a></small>
124
+ </h2>
125
+
126
+ <ul class="summary">
127
+
128
+ <li class="public ">
129
+ <span class="summary_signature">
130
+
131
+ <a href="#multi_tenant-instance_method" title="#multi_tenant (instance method)">#<strong>multi_tenant</strong>(tenant_name, options = {}) &#x21d2; Object </a>
132
+
133
+
134
+
135
+ </span>
136
+
137
+
138
+
139
+
140
+
141
+
142
+
143
+
144
+
145
+ <span class="summary_desc"><div class='inline'>
146
+ <p>executes when multi_tenant method is called in the model.</p>
147
+ </div></span>
148
+
149
+ </li>
150
+
151
+
152
+ </ul>
153
+
154
+
155
+
156
+
157
+ <div id="instance_method_details" class="method_details_list">
158
+ <h2>Instance Method Details</h2>
159
+
160
+
161
+ <div class="method_details first">
162
+ <h3 class="signature first" id="multi_tenant-instance_method">
163
+
164
+ #<strong>multi_tenant</strong>(tenant_name, options = {}) &#x21d2; <tt>Object</tt>
165
+
166
+
167
+
168
+
169
+
170
+ </h3><div class="docstring">
171
+ <div class="discussion">
172
+
173
+ <p>executes when multi_tenant method is called in the model. This method adds the following methods to the model that calls it. scoped_by_tenant? - returns true if the model is scoped by tenant partition_key - returns the partition key for the model primary_key - returns the primary key for the model</p>
174
+
175
+
176
+ </div>
177
+ </div>
178
+ <div class="tags">
179
+
180
+
181
+ </div><table class="source_code">
182
+ <tr>
183
+ <td>
184
+ <pre class="lines">
185
+
186
+
187
+ 16
188
+ 17
189
+ 18
190
+ 19
191
+ 20
192
+ 21
193
+ 22
194
+ 23
195
+ 24
196
+ 25
197
+ 26
198
+ 27
199
+ 28
200
+ 29
201
+ 30
202
+ 31
203
+ 32
204
+ 33
205
+ 34
206
+ 35
207
+ 36
208
+ 37
209
+ 38
210
+ 39
211
+ 40
212
+ 41
213
+ 42
214
+ 43
215
+ 44
216
+ 45
217
+ 46
218
+ 47
219
+ 48
220
+ 49
221
+ 50
222
+ 51
223
+ 52
224
+ 53
225
+ 54
226
+ 55
227
+ 56
228
+ 57
229
+ 58
230
+ 59
231
+ 60
232
+ 61
233
+ 62
234
+ 63
235
+ 64
236
+ 65
237
+ 66
238
+ 67
239
+ 68
240
+ 69
241
+ 70
242
+ 71
243
+ 72
244
+ 73
245
+ 74
246
+ 75
247
+ 76
248
+ 77
249
+ 78
250
+ 79
251
+ 80
252
+ 81
253
+ 82
254
+ 83
255
+ 84
256
+ 85
257
+ 86
258
+ 87
259
+ 88
260
+ 89
261
+ 90
262
+ 91
263
+ 92
264
+ 93
265
+ 94
266
+ 95
267
+ 96
268
+ 97
269
+ 98
270
+ 99
271
+ 100
272
+ 101
273
+ 102
274
+ 103
275
+ 104
276
+ 105
277
+ 106
278
+ 107
279
+ 108
280
+ 109
281
+ 110
282
+ 111
283
+ 112
284
+ 113
285
+ 114
286
+ 115
287
+ 116
288
+ 117
289
+ 118
290
+ 119
291
+ 120
292
+ 121
293
+ 122
294
+ 123
295
+ 124
296
+ 125
297
+ 126
298
+ 127
299
+ 128
300
+ 129
301
+ 130
302
+ 131
303
+ 132
304
+ 133
305
+ 134
306
+ 135
307
+ 136
308
+ 137
309
+ 138
310
+ 139
311
+ 140
312
+ 141
313
+ 142
314
+ 143
315
+ 144
316
+ 145
317
+ 146
318
+ 147
319
+ 148
320
+ 149
321
+ 150
322
+ 151
323
+ 152
324
+ 153
325
+ 154
326
+ 155
327
+ 156
328
+ 157</pre>
329
+ </td>
330
+ <td>
331
+ <pre class="code"><span class="info file"># File 'lib/activerecord-multi-tenant/model_extensions.rb', line 16</span>
332
+
333
+ <span class='kw'>def</span> <span class='id identifier rubyid_multi_tenant'>multi_tenant</span><span class='lparen'>(</span><span class='id identifier rubyid_tenant_name'>tenant_name</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
334
+ <span class='kw'>if</span> <span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_underscore'>underscore</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span> <span class='op'>==</span> <span class='id identifier rubyid_tenant_name'>tenant_name</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='op'>!</span><span class='id identifier rubyid_table_name'>table_name</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_table_name'>table_name</span><span class='period'>.</span><span class='id identifier rubyid_singularize'>singularize</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span> <span class='op'>==</span> <span class='id identifier rubyid_tenant_name'>tenant_name</span><span class='rparen'>)</span>
335
+ <span class='kw'>unless</span> <span class='const'><span class='object_link'><a href="../MultiTenant.html" title="MultiTenant (module)">MultiTenant</a></span></span><span class='period'>.</span><span class='id identifier rubyid_with_write_only_mode_enabled?'><span class='object_link'><a href="../MultiTenant.html#with_write_only_mode_enabled%3F-class_method" title="MultiTenant.with_write_only_mode_enabled? (method)">with_write_only_mode_enabled?</a></span></span>
336
+ <span class='comment'># This is the tenant model itself. Workaround for https://github.com/citusdata/citus/issues/687
337
+ </span> <span class='id identifier rubyid_before_create'>before_create</span> <span class='id identifier rubyid_lambda'>lambda</span> <span class='lbrace'>{</span>
338
+ <span class='id identifier rubyid_id'>id</span> <span class='op'>=</span> <span class='kw'>if</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_columns_hash'>columns_hash</span><span class='lbracket'>[</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_primary_key'>primary_key</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span> <span class='op'>==</span> <span class='symbol'>:uuid</span>
339
+ <span class='const'>SecureRandom</span><span class='period'>.</span><span class='id identifier rubyid_uuid'>uuid</span>
340
+ <span class='kw'>else</span>
341
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_connection'>connection</span><span class='period'>.</span><span class='id identifier rubyid_select_value'>select_value</span><span class='lparen'>(</span>
342
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>SELECT nextval(&#39;</span><span class='embexpr_beg'>#{</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_table_name'>table_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>_</span><span class='embexpr_beg'>#{</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_primary_key'>primary_key</span><span class='embexpr_end'>}</span><span class='tstring_content'>_seq&#39;::regclass)</span><span class='tstring_end'>&quot;</span></span>
343
+ <span class='rparen'>)</span>
344
+ <span class='kw'>end</span>
345
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span> <span class='op'>||=</span> <span class='id identifier rubyid_id'>id</span>
346
+ <span class='rbrace'>}</span>
347
+ <span class='kw'>end</span>
348
+ <span class='kw'>else</span>
349
+ <span class='kw'>class</span> <span class='op'>&lt;&lt;</span> <span class='kw'>self</span>
350
+ <span class='kw'>def</span> <span class='id identifier rubyid_scoped_by_tenant?'>scoped_by_tenant?</span>
351
+ <span class='kw'>true</span>
352
+ <span class='kw'>end</span>
353
+
354
+ <span class='comment'># Allow partition_key to be set from a superclass if not already set in this class
355
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_partition_key'>partition_key</span>
356
+ <span class='ivar'>@partition_key</span> <span class='op'>||=</span> <span class='id identifier rubyid_ancestors'>ancestors</span><span class='period'>.</span><span class='id identifier rubyid_detect'>detect</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='op'>|</span> <span class='id identifier rubyid_k'>k</span><span class='period'>.</span><span class='id identifier rubyid_instance_variable_get'>instance_variable_get</span><span class='lparen'>(</span><span class='symbol'>:@partition_key</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
357
+ <span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:instance_variable_get</span><span class='comma'>,</span> <span class='symbol'>:@partition_key</span><span class='rparen'>)</span>
358
+ <span class='kw'>end</span>
359
+
360
+ <span class='comment'># Avoid primary_key errors when using composite primary keys (e.g. id, tenant_id)
361
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_primary_key'>primary_key</span>
362
+ <span class='kw'>if</span> <span class='kw'>defined?</span><span class='lparen'>(</span><span class='const'>PRIMARY_KEY_NOT_SET</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='op'>!</span><span class='const'>PRIMARY_KEY_NOT_SET</span><span class='period'>.</span><span class='id identifier rubyid_equal?'>equal?</span><span class='lparen'>(</span><span class='ivar'>@primary_key</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='ivar'>@primary_key</span>
363
+ <span class='kw'>return</span> <span class='ivar'>@primary_key</span>
364
+ <span class='kw'>end</span>
365
+
366
+ <span class='id identifier rubyid_primary_object_keys'>primary_object_keys</span> <span class='op'>=</span> <span class='const'>Array</span><span class='period'>.</span><span class='id identifier rubyid_wrap'>wrap</span><span class='lparen'>(</span><span class='id identifier rubyid_connection'>connection</span><span class='period'>.</span><span class='id identifier rubyid_schema_cache'>schema_cache</span><span class='period'>.</span><span class='id identifier rubyid_primary_keys'>primary_keys</span><span class='lparen'>(</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rparen'>)</span><span class='rparen'>)</span> <span class='op'>-</span> <span class='lbracket'>[</span><span class='id identifier rubyid_partition_key'>partition_key</span><span class='rbracket'>]</span>
367
+
368
+ <span class='ivar'>@primary_key</span> <span class='op'>=</span> <span class='kw'>if</span> <span class='id identifier rubyid_primary_object_keys'>primary_object_keys</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='op'>==</span> <span class='int'>1</span>
369
+ <span class='id identifier rubyid_primary_object_keys'>primary_object_keys</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
370
+ <span class='kw'>elsif</span> <span class='id identifier rubyid_connection'>connection</span><span class='period'>.</span><span class='id identifier rubyid_schema_cache'>schema_cache</span><span class='period'>.</span><span class='id identifier rubyid_columns_hash'>columns_hash</span><span class='lparen'>(</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span> <span class='const'><span class='object_link'><a href="#DEFAULT_ID_FIELD-constant" title="MultiTenant::ModelExtensionsClassMethods::DEFAULT_ID_FIELD (constant)">DEFAULT_ID_FIELD</a></span></span>
371
+ <span class='const'><span class='object_link'><a href="#DEFAULT_ID_FIELD-constant" title="MultiTenant::ModelExtensionsClassMethods::DEFAULT_ID_FIELD (constant)">DEFAULT_ID_FIELD</a></span></span>
372
+ <span class='kw'>end</span>
373
+ <span class='kw'>end</span>
374
+
375
+ <span class='kw'>def</span> <span class='id identifier rubyid_inherited'>inherited</span><span class='lparen'>(</span><span class='id identifier rubyid_subclass'>subclass</span><span class='rparen'>)</span>
376
+ <span class='kw'>super</span>
377
+ <span class='const'><span class='object_link'><a href="../MultiTenant.html" title="MultiTenant (module)">MultiTenant</a></span></span><span class='period'>.</span><span class='id identifier rubyid_register_multi_tenant_model'><span class='object_link'><a href="../MultiTenant.html#register_multi_tenant_model-class_method" title="MultiTenant.register_multi_tenant_model (method)">register_multi_tenant_model</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_subclass'>subclass</span><span class='rparen'>)</span>
378
+ <span class='kw'>end</span>
379
+ <span class='kw'>end</span>
380
+
381
+ <span class='const'><span class='object_link'><a href="../MultiTenant.html" title="MultiTenant (module)">MultiTenant</a></span></span><span class='period'>.</span><span class='id identifier rubyid_register_multi_tenant_model'><span class='object_link'><a href="../MultiTenant.html#register_multi_tenant_model-class_method" title="MultiTenant.register_multi_tenant_model (method)">register_multi_tenant_model</a></span></span><span class='lparen'>(</span><span class='kw'>self</span><span class='rparen'>)</span>
382
+
383
+ <span class='ivar'>@partition_key</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:partition_key</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='const'><span class='object_link'><a href="../MultiTenant.html" title="MultiTenant (module)">MultiTenant</a></span></span><span class='period'>.</span><span class='id identifier rubyid_partition_key'><span class='object_link'><a href="../MultiTenant.html#partition_key-class_method" title="MultiTenant.partition_key (method)">partition_key</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_tenant_name'>tenant_name</span><span class='rparen'>)</span>
384
+ <span class='id identifier rubyid_partition_key'>partition_key</span> <span class='op'>=</span> <span class='ivar'>@partition_key</span>
385
+
386
+ <span class='comment'># Create an implicit belongs_to association only if tenant class exists
387
+ </span> <span class='kw'>if</span> <span class='const'><span class='object_link'><a href="../MultiTenant.html" title="MultiTenant (module)">MultiTenant</a></span></span><span class='period'>.</span><span class='id identifier rubyid_tenant_klass_defined?'><span class='object_link'><a href="../MultiTenant.html#tenant_klass_defined%3F-class_method" title="MultiTenant.tenant_klass_defined? (method)">tenant_klass_defined?</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_tenant_name'>tenant_name</span><span class='rparen'>)</span>
388
+ <span class='id identifier rubyid_belongs_to'>belongs_to</span> <span class='id identifier rubyid_tenant_name'>tenant_name</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_slice'>slice</span><span class='lparen'>(</span><span class='symbol'>:class_name</span><span class='comma'>,</span> <span class='symbol'>:inverse_of</span><span class='comma'>,</span> <span class='symbol'>:optional</span><span class='rparen'>)</span>
389
+ <span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='label'>foreign_key:</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:partition_key</span><span class='rbracket'>]</span><span class='rparen'>)</span>
390
+ <span class='kw'>end</span>
391
+
392
+ <span class='comment'># New instances should have the tenant set
393
+ </span> <span class='id identifier rubyid_after_initialize'>after_initialize</span> <span class='id identifier rubyid_proc'>proc</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_record'>record</span><span class='op'>|</span>
394
+ <span class='kw'>if</span> <span class='const'><span class='object_link'><a href="../MultiTenant.html" 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="../MultiTenant.html#current_tenant_id-class_method" title="MultiTenant.current_tenant_id (method)">current_tenant_id</a></span></span> <span class='op'>&amp;&amp;</span>
395
+ <span class='lparen'>(</span><span class='op'>!</span><span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_attribute_present?'>attribute_present?</span><span class='lparen'>(</span><span class='id identifier rubyid_partition_key'>partition_key</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_public_send'>public_send</span><span class='lparen'>(</span><span class='id identifier rubyid_partition_key'>partition_key</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span><span class='rparen'>)</span>
396
+ <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_public_send'>public_send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_partition_key'>partition_key</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='comma'>,</span> <span class='const'><span class='object_link'><a href="../MultiTenant.html" 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="../MultiTenant.html#current_tenant_id-class_method" title="MultiTenant.current_tenant_id (method)">current_tenant_id</a></span></span><span class='rparen'>)</span>
397
+ <span class='kw'>end</span>
398
+ <span class='rbrace'>}</span>
399
+
400
+ <span class='comment'># Below block adds the following methods to the model that calls it.
401
+ </span> <span class='comment'># partition_key= - returns the partition key for the model.class &lt;&lt; self &#39;partition&#39; method defined above
402
+ </span> <span class='comment'># is the getter method. Here, there is additional check to assure that the tenant id is not changed once set
403
+ </span> <span class='comment'># tenant_name- returns the name of the tenant model. Its setter and getter methods defined separately
404
+ </span> <span class='comment'># Getter checks for the tenant association and if it is not loaded, returns the current tenant id set
405
+ </span> <span class='comment'># in the MultiTenant module
406
+ </span> <span class='id identifier rubyid_to_include'>to_include</span> <span class='op'>=</span> <span class='const'>Module</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='kw'>do</span>
407
+ <span class='id identifier rubyid_define_method'>define_method</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_partition_key'>partition_key</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_tenant_id'>tenant_id</span><span class='op'>|</span>
408
+ <span class='id identifier rubyid_write_attribute'>write_attribute</span><span class='lparen'>(</span><span class='id identifier rubyid_partition_key'>partition_key</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='comma'>,</span> <span class='id identifier rubyid_tenant_id'>tenant_id</span><span class='rparen'>)</span>
409
+
410
+ <span class='comment'># Rails 5 `attribute_will_change!` uses the attribute-method-call rather than `read_attribute`
411
+ </span> <span class='comment'># and will raise ActiveModel::MissingAttributeError if that column was not selected.
412
+ </span> <span class='comment'># This is rescued as NoMethodError and in MRI attribute_was is assigned an arbitrary Object
413
+ </span> <span class='id identifier rubyid_was'>was</span> <span class='op'>=</span> <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_partition_key'>partition_key</span><span class='embexpr_end'>}</span><span class='tstring_content'>_was</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
414
+ <span class='id identifier rubyid_was_nil_or_skipped'>was_nil_or_skipped</span> <span class='op'>=</span> <span class='id identifier rubyid_was'>was</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>||</span> <span class='id identifier rubyid_was'>was</span><span class='period'>.</span><span class='id identifier rubyid_instance_of?'>instance_of?</span><span class='lparen'>(</span><span class='const'>Object</span><span class='rparen'>)</span>
415
+
416
+ <span class='kw'>if</span> <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_partition_key'>partition_key</span><span class='embexpr_end'>}</span><span class='tstring_content'>_changed?</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_persisted?'>persisted?</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_was_nil_or_skipped'>was_nil_or_skipped</span>
417
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="../MultiTenant.html" title="MultiTenant (module)">MultiTenant</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="TenantIsImmutable.html" title="MultiTenant::TenantIsImmutable (class)">TenantIsImmutable</a></span></span>
418
+ <span class='kw'>end</span>
419
+
420
+ <span class='id identifier rubyid_tenant_id'>tenant_id</span>
421
+ <span class='kw'>end</span>
422
+
423
+ <span class='kw'>if</span> <span class='const'><span class='object_link'><a href="../MultiTenant.html" title="MultiTenant (module)">MultiTenant</a></span></span><span class='period'>.</span><span class='id identifier rubyid_tenant_klass_defined?'><span class='object_link'><a href="../MultiTenant.html#tenant_klass_defined%3F-class_method" title="MultiTenant.tenant_klass_defined? (method)">tenant_klass_defined?</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_tenant_name'>tenant_name</span><span class='rparen'>)</span>
424
+ <span class='id identifier rubyid_define_method'>define_method</span> <span class='tstring'><span class='tstring_beg'>&quot;</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'>=</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_model'>model</span><span class='op'>|</span>
425
+ <span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_model'>model</span><span class='rparen'>)</span>
426
+ <span class='kw'>if</span> <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_partition_key'>partition_key</span><span class='embexpr_end'>}</span><span class='tstring_content'>_changed?</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_persisted?'>persisted?</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_partition_key'>partition_key</span><span class='embexpr_end'>}</span><span class='tstring_content'>_was</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
427
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="../MultiTenant.html" title="MultiTenant (module)">MultiTenant</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="TenantIsImmutable.html" title="MultiTenant::TenantIsImmutable (class)">TenantIsImmutable</a></span></span>
428
+ <span class='kw'>end</span>
429
+
430
+ <span class='id identifier rubyid_model'>model</span>
431
+ <span class='kw'>end</span>
432
+
433
+ <span class='id identifier rubyid_define_method'>define_method</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='kw'>do</span>
434
+ <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_association'>association</span><span class='lparen'>(</span><span class='id identifier rubyid_tenant_name'>tenant_name</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_loaded?'>loaded?</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='const'><span class='object_link'><a href="../MultiTenant.html" title="MultiTenant (module)">MultiTenant</a></span></span><span class='period'>.</span><span class='id identifier rubyid_current_tenant_is_id?'><span class='object_link'><a href="../MultiTenant.html#current_tenant_is_id%3F-class_method" title="MultiTenant.current_tenant_is_id? (method)">current_tenant_is_id?</a></span></span> <span class='op'>&amp;&amp;</span>
435
+ <span class='const'><span class='object_link'><a href="../MultiTenant.html" 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="../MultiTenant.html#current_tenant_id-class_method" title="MultiTenant.current_tenant_id (method)">current_tenant_id</a></span></span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_public_send'>public_send</span><span class='lparen'>(</span><span class='id identifier rubyid_partition_key'>partition_key</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='const'><span class='object_link'><a href="../MultiTenant.html" 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="../MultiTenant.html#current_tenant_id-class_method" title="MultiTenant.current_tenant_id (method)">current_tenant_id</a></span></span>
436
+ <span class='const'><span class='object_link'><a href="../MultiTenant.html" title="MultiTenant (module)">MultiTenant</a></span></span><span class='period'>.</span><span class='id identifier rubyid_current_tenant'><span class='object_link'><a href="../MultiTenant.html#current_tenant-class_method" title="MultiTenant.current_tenant (method)">current_tenant</a></span></span>
437
+ <span class='kw'>else</span>
438
+ <span class='kw'>super</span><span class='lparen'>(</span><span class='rparen'>)</span>
439
+ <span class='kw'>end</span>
440
+ <span class='kw'>end</span>
441
+ <span class='kw'>end</span>
442
+ <span class='kw'>end</span>
443
+ <span class='id identifier rubyid_include'>include</span> <span class='id identifier rubyid_to_include'>to_include</span>
444
+
445
+ <span class='comment'># Below blocks sets tenant_id for the current session with the tenant_id of the record
446
+ </span> <span class='comment'># If the tenant is not set for the `session.After` the save operation current session tenant is set to nil
447
+ </span> <span class='comment'># If tenant is set for the session, save operation is performed as it is
448
+ </span> <span class='id identifier rubyid_around_save'>around_save</span> <span class='id identifier rubyid_lambda'>lambda</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_record'>record</span><span class='comma'>,</span> <span class='id identifier rubyid_block'>block</span><span class='op'>|</span>
449
+ <span class='id identifier rubyid_record_tenant'>record_tenant</span> <span class='op'>=</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_attribute_was'>attribute_was</span><span class='lparen'>(</span><span class='id identifier rubyid_partition_key'>partition_key</span><span class='rparen'>)</span>
450
+ <span class='kw'>if</span> <span class='id identifier rubyid_persisted?'>persisted?</span> <span class='op'>&amp;&amp;</span> <span class='const'><span class='object_link'><a href="../MultiTenant.html" 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="../MultiTenant.html#current_tenant_id-class_method" title="MultiTenant.current_tenant_id (method)">current_tenant_id</a></span></span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_record_tenant'>record_tenant</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
451
+ <span class='const'><span class='object_link'><a href="../MultiTenant.html" title="MultiTenant (module)">MultiTenant</a></span></span><span class='period'>.</span><span class='id identifier rubyid_with'><span class='object_link'><a href="../MultiTenant.html#with-class_method" title="MultiTenant.with (method)">with</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_public_send'>public_send</span><span class='lparen'>(</span><span class='id identifier rubyid_partition_key'>partition_key</span><span class='rparen'>)</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='id identifier rubyid_block'>block</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span> <span class='rbrace'>}</span>
452
+ <span class='kw'>else</span>
453
+ <span class='id identifier rubyid_block'>block</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span>
454
+ <span class='kw'>end</span>
455
+ <span class='rbrace'>}</span>
456
+
457
+ <span class='id identifier rubyid_around_update'>around_update</span> <span class='id identifier rubyid_lambda'>lambda</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_record'>record</span><span class='comma'>,</span> <span class='id identifier rubyid_block'>block</span><span class='op'>|</span>
458
+ <span class='id identifier rubyid_record_tenant'>record_tenant</span> <span class='op'>=</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_attribute_was'>attribute_was</span><span class='lparen'>(</span><span class='id identifier rubyid_partition_key'>partition_key</span><span class='rparen'>)</span>
459
+ <span class='kw'>if</span> <span class='const'><span class='object_link'><a href="../MultiTenant.html" 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="../MultiTenant.html#current_tenant_id-class_method" title="MultiTenant.current_tenant_id (method)">current_tenant_id</a></span></span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_record_tenant'>record_tenant</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
460
+ <span class='const'><span class='object_link'><a href="../MultiTenant.html" title="MultiTenant (module)">MultiTenant</a></span></span><span class='period'>.</span><span class='id identifier rubyid_with'><span class='object_link'><a href="../MultiTenant.html#with-class_method" title="MultiTenant.with (method)">with</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_public_send'>public_send</span><span class='lparen'>(</span><span class='id identifier rubyid_partition_key'>partition_key</span><span class='rparen'>)</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='id identifier rubyid_block'>block</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span> <span class='rbrace'>}</span>
461
+ <span class='kw'>else</span>
462
+ <span class='id identifier rubyid_block'>block</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span>
463
+ <span class='kw'>end</span>
464
+ <span class='rbrace'>}</span>
465
+
466
+ <span class='id identifier rubyid_around_destroy'>around_destroy</span> <span class='id identifier rubyid_lambda'>lambda</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_record'>record</span><span class='comma'>,</span> <span class='id identifier rubyid_block'>block</span><span class='op'>|</span>
467
+ <span class='kw'>if</span> <span class='const'><span class='object_link'><a href="../MultiTenant.html" 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="../MultiTenant.html#current_tenant_id-class_method" title="MultiTenant.current_tenant_id (method)">current_tenant_id</a></span></span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
468
+ <span class='const'><span class='object_link'><a href="../MultiTenant.html" title="MultiTenant (module)">MultiTenant</a></span></span><span class='period'>.</span><span class='id identifier rubyid_with'><span class='object_link'><a href="../MultiTenant.html#with-class_method" title="MultiTenant.with (method)">with</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_public_send'>public_send</span><span class='lparen'>(</span><span class='id identifier rubyid_partition_key'>partition_key</span><span class='rparen'>)</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='id identifier rubyid_block'>block</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span> <span class='rbrace'>}</span>
469
+ <span class='kw'>else</span>
470
+ <span class='id identifier rubyid_block'>block</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span>
471
+ <span class='kw'>end</span>
472
+ <span class='rbrace'>}</span>
473
+ <span class='kw'>end</span>
474
+ <span class='kw'>end</span></pre>
475
+ </td>
476
+ </tr>
477
+ </table>
478
+ </div>
479
+
480
+ </div>
481
+
482
+ </div>
483
+
484
+ <div id="footer">
485
+ Generated on Sat May 27 10:16:24 2023 by
486
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
487
+ 0.9.34 (ruby-3.2.2).
488
+ </div>
489
+
490
+ </div>
491
+ </body>
492
+ </html>