activerecord-multi-tenant 2.1.2 → 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: 6da68db2d8d58cc00bc0fd9de50b85544fff943596c4ed7fb9211380419e1b1b
4
- data.tar.gz: a5126bdd3b733a6e58c0c5d1e63e7bfe27b76a18fd790219ee08641379019336
3
+ metadata.gz: 29d653eb35952bb70e983799cae4b5c88fdcbf852e1ba16a730362a01f18d327
4
+ data.tar.gz: 6fa61c33ed3f99eff5d214f195544547ac67bf4d81d60adbe18c4d1ecb7432a9
5
5
  SHA512:
6
- metadata.gz: 69be1d704a41ee78b28c9f23cb8bb1f606a97146c979ca087eeef1d43fa4a482bacedc21317677862f427567d98abcc4199f029eb04719b2dab363bb29a2160d
7
- data.tar.gz: a6495adf22bbd72f03e15f8056e57c9dbabfaab9dde1b15fc3365794a1a8c25f624e094e82de2b7ed1648dcad990b410b6f3b97e6369534aa7ea6ee528505360
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
- 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, &block) }
137
+ MultiTenant.with(#{owner}.public_send(#{owner}.class.partition_key)) { #{original_method_name}(...) }
121
138
  else
122
- #{original_method_name}(*args, &block)
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.2'
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.2
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-26 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