mobility 1.2.3 → 1.2.4

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: 7b94201a6b91ad2fff4818aa37fa4fd99df97944d98f3888af6b76f732f71658
4
- data.tar.gz: 8be29d872e1488575253302daa13b46d5f065c5dd9aa35c526c0fd561ae478c5
3
+ metadata.gz: d0dd974f8a077b31fc0ab41df158e4cac50c6aee4e7fd66348db1ed2ef5f78f9
4
+ data.tar.gz: ea72521a4bb8daedf08d3012353c591ec47f76e3fe6ec3c10b87e331a5404db9
5
5
  SHA512:
6
- metadata.gz: a7afca6199b32df4105ad2bd55d33c6213677d424d6a4bb22e5d39e33b649de2e256a04b1f03e9c33d6374e5c4ec7858a7de9b2a0e190cc1a417da895981b7a0
7
- data.tar.gz: 23ef1c7ca95c54872c5504a50af6c94116c94157586ba755a9ed57e6ca878647a1693460232840ed58c47f5807b6fd6c6db2283c397faf7a7e3402e93f675be3
6
+ metadata.gz: 15b9df45774c9b3d4ae343b2f083b2a85ddfd7585283998b0dc624aa62eee5c6e5fade0737ae78b3dd728dd273a03dcf10afecabcca6eb8f90400619de0a7fa4
7
+ data.tar.gz: 1f199821139bf35b4e176f52dac0249f482ffb5edc9d7957d437e9262a908812fab01ba5dea52e18a9b1f37f92744b345c34ca0c84d97da0641f9fab19577704
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## 1.2
4
4
 
5
+ ### 1.2.4
6
+ - Fix fallbacks performance regression
7
+ ([#548](https://github.com/shioyama/mobility/pull/548))
8
+
5
9
  ### 1.2.3
6
10
  - Fix passing wrong options to super in fallbacks plugin
7
11
  ([#539](https://github.com/shioyama/mobility/pull/539))
data/Gemfile.lock CHANGED
@@ -1,6 +1,6 @@
1
1
  GIT
2
2
  remote: https://github.com/rails/rails.git
3
- revision: 0a751a021bfc0c71bb2a10ff8af9654c785c94f1
3
+ revision: 5647a9c1ced68d20338552d47a3b755e10a271c4
4
4
  branch: main
5
5
  specs:
6
6
  activemodel (7.0.0.alpha2)
data/README.md CHANGED
@@ -55,7 +55,7 @@ Installation
55
55
  Add this line to your application's Gemfile:
56
56
 
57
57
  ```ruby
58
- gem 'mobility', '~> 1.2.3'
58
+ gem 'mobility', '~> 1.2.4'
59
59
  ```
60
60
 
61
61
  ### ActiveRecord (Rails)
@@ -117,10 +117,21 @@ the current locale was +nil+.
117
117
  # Applies fallbacks plugin to attributes. Completely disables fallbacks
118
118
  # on model if option is +false+.
119
119
  included_hook do |_, backend_class|
120
- backend_class.include(BackendInstanceMethods) unless options[:fallbacks] == false
121
- # This is weird. We need to find a better way to allow customization of
122
- # rarely-customized code like this.
123
- backend_class.define_method(:generate_fallbacks, &method(:generate_fallbacks))
120
+ unless options[:fallbacks] == false
121
+ backend_class.include(BackendInstanceMethods)
122
+
123
+ fallbacks =
124
+ if options[:fallbacks].is_a?(Hash)
125
+ generate_fallbacks(options[:fallbacks])
126
+ elsif options[:fallbacks] == true
127
+ generate_fallbacks({})
128
+ else
129
+ ::Hash.new { [] }
130
+ end
131
+
132
+ backend_class.singleton_class.attr_reader :fallbacks
133
+ backend_class.instance_variable_set(:@fallbacks, fallbacks)
134
+ end
124
135
  end
125
136
 
126
137
  private
@@ -140,7 +151,7 @@ the current locale was +nil+.
140
151
  def read(locale, fallback: true, **kwargs)
141
152
  return super(locale, **kwargs) if !fallback || kwargs[:locale]
142
153
 
143
- locales = fallback == true ? fallbacks[locale] : [locale, *fallback]
154
+ locales = fallback == true ? self.class.fallbacks[locale] : [locale, *fallback]
144
155
  locales.each do |fallback_locale|
145
156
  value = super(fallback_locale, **kwargs)
146
157
  return value if Util.present?(value)
@@ -148,18 +159,6 @@ the current locale was +nil+.
148
159
 
149
160
  super(locale, **kwargs)
150
161
  end
151
-
152
- private
153
-
154
- def fallbacks
155
- if options[:fallbacks].is_a?(Hash)
156
- generate_fallbacks(options[:fallbacks])
157
- elsif options[:fallbacks] == true
158
- generate_fallbacks({})
159
- else
160
- ::Hash.new { [] }
161
- end
162
- end
163
162
  end
164
163
  end
165
164
 
@@ -8,7 +8,7 @@ module Mobility
8
8
  module VERSION
9
9
  MAJOR = 1
10
10
  MINOR = 2
11
- TINY = 3
11
+ TINY = 4
12
12
  PRE = nil
13
13
 
14
14
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mobility
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Salzberg
@@ -34,7 +34,7 @@ cert_chain:
34
34
  eBMcZq0d1tbtv1M1UXND9mOfhLZ31YvoSTPkrJiRpljUNgD0+ugelnr1/5X/9k8y
35
35
  J9QOd3C5jpSShf/HMvpJnFuSYFm19cH9GrHjvw==
36
36
  -----END CERTIFICATE-----
37
- date: 2021-10-25 00:00:00.000000000 Z
37
+ date: 2021-11-28 00:00:00.000000000 Z
38
38
  dependencies:
39
39
  - !ruby/object:Gem::Dependency
40
40
  name: request_store
metadata.gz.sig CHANGED
@@ -1,3 +1,3 @@
1
- |��Q��Xԁ�S%oj8ۿ���Y���-�D����'����VC��(f9EF��P w̌xg;z�(@��B"����LCx��H���ht�v�����M��˚���YOT
2
- ,�4nOD>1��ȧ�h�������/Hf�حUP'ؘ�0e=d�S> l.���I��?��St|���k���?�ԥ�k�.��j�;=^�X7B��?�߻�� _u���9��(+�����n @����>�bS�\y�Nn}�P�]7u ʦq�D�0:�.�[f�r�P*o���$L%����m���g�P["�^�
3
- b'f��U�G�cO��r������׭*?�Kx0�Tʰ�l�q��(��%���ο6ݑ�MAA���$
1
+ �}�=�''gs0�J)�������^�(����h*G��=^ �~V2����;\v_6K�݆f�ߵPPE�h�G�۶�$���Χ�5k�uS
2
+ 26�C;�}SMw�k�bL�
3
+ ���Yԝ������{uT��0Lwz��:qJ-8���<g�G�>#
4
+ jg_ko���^^ɓO�͜B��ݯ��/��~xGV���Vc��Ww��ѥVu"�۟2�#�C��hڴW�J�^.U���+蕕&8�)~��[���6������S�&��6mX�5F�~B4.�6�t�&�4������#����Ң��l�$����4-�Uc7d��A*����J��g��;tD�$