activerecord-multi-tenant 2.1.1 → 2.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e198970d8d5a4db04c8e203e28021668c765fdde78f9bb9a7cd0e6c577bfbe0e
4
- data.tar.gz: 6abb30aac520063dbef7ddc5689714ef1dd9eb691aa382498b30c8bbcf03844b
3
+ metadata.gz: 29d653eb35952bb70e983799cae4b5c88fdcbf852e1ba16a730362a01f18d327
4
+ data.tar.gz: 6fa61c33ed3f99eff5d214f195544547ac67bf4d81d60adbe18c4d1ecb7432a9
5
5
  SHA512:
6
- metadata.gz: 5010dbbd2a8036ad5a3adae79a49567a279a318931ffe832663dd2430f455d1895e26cca6d96456484b894cc241cca21fbab31aa301f9ab4ef0538a4266b4005
7
- data.tar.gz: e94b7ee0f619b0763879efefbae3a69792e00e8b9f2a2661a82666d4c129decea132f20b44999177bdc0162dec0e9b3cac4f402d70a76fb14518e283f4441d6c
6
+ metadata.gz: 0f9b6bc791de06c8c3cfef7cd4f458cebe9412bbe0baf01f3ff102636810a3fa6b2f1ec63aacfd9c4989956f14fa78b4a29d862d399ae634cf44def50db7f594
7
+ data.tar.gz: 46dcda19e38662c310d4c149f01151422461157c16012a07060f64735667d75ff1040956db0b7428ff7a76c2ee84b56facd77c86b063bfffed65e44341a37323
data/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
1
  # Changelog
2
2
 
3
- ## 2.1.0 2022-10-20
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
+
6
+ ## 2.1.2 2022-10-26
7
+ * Fixes issue when wraping methods that require a block [#162](https://github.com/citusdata/activerecord-multi-tenant/pull/162)
8
+
9
+ ## 2.1.1 2022-10-20
4
10
  * Fix query building for models with mismatched partition_keys [#150](https://github.com/citusdata/activerecord-multi-tenant/pull/150)
5
11
  * Identify tenant even if class name is nonstandard [#152](https://github.com/citusdata/activerecord-multi-tenant/pull/152)
6
12
  * Add current_tenant_id to WHERE clauses when calling methods on activerecord instance or its associations [#154](https://github.com/citusdata/activerecord-multi-tenant/pull/154)
@@ -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
- def self.wrap_methods(klass, owner, *method_names)
114
- method_names.each do |method_name|
115
- original_method_name = :"_mt_original_#{method_name}"
116
- klass.class_eval <<-CODE, __FILE__, __LINE__ + 1
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}(*args, &block)
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}(*args) }
137
+ MultiTenant.with(#{owner}.public_send(#{owner}.class.partition_key)) { #{original_method_name}(...) }
121
138
  else
122
- #{original_method_name}(*args)
139
+ #{original_method_name}(...)
123
140
  end
124
141
  end
125
- CODE
142
+ CODE
143
+ end
126
144
  end
127
145
  end
128
146
 
@@ -1,3 +1,3 @@
1
1
  module MultiTenant
2
- VERSION = '2.1.1'
2
+ VERSION = '2.1.3'
3
3
  end
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.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-20 00:00:00.000000000 Z
11
+ date: 2022-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails