activerecord-multi-tenant 2.1.2 → 2.1.3
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/CHANGELOG.md +3 -0
- data/lib/activerecord-multi-tenant/multi_tenant.rb +26 -8
- data/lib/activerecord-multi-tenant/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29d653eb35952bb70e983799cae4b5c88fdcbf852e1ba16a730362a01f18d327
|
4
|
+
data.tar.gz: 6fa61c33ed3f99eff5d214f195544547ac67bf4d81d60adbe18c4d1ecb7432a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f9b6bc791de06c8c3cfef7cd4f458cebe9412bbe0baf01f3ff102636810a3fa6b2f1ec63aacfd9c4989956f14fa78b4a29d862d399ae634cf44def50db7f594
|
7
|
+
data.tar.gz: 46dcda19e38662c310d4c149f01151422461157c16012a07060f64735667d75ff1040956db0b7428ff7a76c2ee84b56facd77c86b063bfffed65e44341a37323
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 2.1.3 2022-10-27
|
4
|
+
* Error when calling a method that takes keyword arguments with MultiTenant.wrap_methods [#164](https://github.com/citusdata/activerecord-multi-tenant/pull/164)
|
5
|
+
|
3
6
|
## 2.1.2 2022-10-26
|
4
7
|
* Fixes issue when wraping methods that require a block [#162](https://github.com/citusdata/activerecord-multi-tenant/pull/162)
|
5
8
|
|
@@ -110,19 +110,37 @@ module MultiTenant
|
|
110
110
|
end
|
111
111
|
|
112
112
|
# Wrap calls to any of `method_names` on an instance Class `klass` with MultiTenant.with when `'owner'` (evaluated in context of the klass instance) is a ActiveRecord model instance that is multi-tenant
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
113
|
+
if Gem::Version.create(RUBY_VERSION) < Gem::Version.new("2.7.0")
|
114
|
+
def self.wrap_methods(klass, owner, *method_names)
|
115
|
+
method_names.each do |method_name|
|
116
|
+
original_method_name = :"_mt_original_#{method_name}"
|
117
|
+
klass.class_eval <<-CODE, __FILE__, __LINE__ + 1
|
118
|
+
alias_method :#{original_method_name}, :#{method_name}
|
119
|
+
def #{method_name}(*args, &block)
|
120
|
+
if MultiTenant.multi_tenant_model_for_table(#{owner}.class.table_name).present? && #{owner}.persisted? && MultiTenant.current_tenant_id.nil?
|
121
|
+
MultiTenant.with(#{owner}.public_send(#{owner}.class.partition_key)) { #{original_method_name}(*args, &block) }
|
122
|
+
else
|
123
|
+
#{original_method_name}(*args, &block)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
CODE
|
127
|
+
end
|
128
|
+
end
|
129
|
+
else
|
130
|
+
def self.wrap_methods(klass, owner, *method_names)
|
131
|
+
method_names.each do |method_name|
|
132
|
+
original_method_name = :"_mt_original_#{method_name}"
|
133
|
+
klass.class_eval <<-CODE, __FILE__, __LINE__ + 1
|
117
134
|
alias_method :#{original_method_name}, :#{method_name}
|
118
|
-
def #{method_name}(
|
135
|
+
def #{method_name}(...)
|
119
136
|
if MultiTenant.multi_tenant_model_for_table(#{owner}.class.table_name).present? && #{owner}.persisted? && MultiTenant.current_tenant_id.nil?
|
120
|
-
MultiTenant.with(#{owner}.public_send(#{owner}.class.partition_key)) { #{original_method_name}(
|
137
|
+
MultiTenant.with(#{owner}.public_send(#{owner}.class.partition_key)) { #{original_method_name}(...) }
|
121
138
|
else
|
122
|
-
#{original_method_name}(
|
139
|
+
#{original_method_name}(...)
|
123
140
|
end
|
124
141
|
end
|
125
|
-
|
142
|
+
CODE
|
143
|
+
end
|
126
144
|
end
|
127
145
|
end
|
128
146
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-multi-tenant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Citus Data
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|