elasticsearch-model-mongoid_extensions 1.1.0 → 1.1.1

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: bff3160ee99ace6e3189b086c28860d85b6e5e199d5b94c221198d2d125fc9fa
4
- data.tar.gz: 6cfe79f4e4697bb67abdacd1b9070038beebd43cebce76bcf55d0d3879b20389
3
+ metadata.gz: 51c2855c08e68e44f7630c57fe03f00cdce0bd4b78de67989436b494f40acc40
4
+ data.tar.gz: 1f72120ee7612d3d873278b6d6cf431232d9db1c5dcc2056bea82c56b39d9ef4
5
5
  SHA512:
6
- metadata.gz: eb092fde421904554da329f4dd18fbddbbd7e2d9cbd87ee05b0a25ddb25b93d7c1c440131378ffaba53c7000169f5fbb044e8ac36e1bb5417be46f46c069cd46
7
- data.tar.gz: bb99f9c27ea8d2dbc4142f7903aa77b3c3557ee600d63e32986d9093ed3141997e28648ba05defbe1bdfeaab2a42d2db1ad7bcee4b221f449bf7c40a39b2b917
6
+ metadata.gz: aa7d34e369a02fc8922bf4742a7e0bf1248ea388ce7d9d7a0b38ba8428284c8433051528d6ba227ac3c92d0d636fed09e48818f341515eed4b435934ce0baad0
7
+ data.tar.gz: bc83083b9d66f8f1c2ed3fbab8f08f030423f673777ef5c3797108f686045ce59492992a84d735a68a24aa164938da86a0805990a6b2b7f188f8623c47544e93
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.1.1
4
+
5
+ * added support for localized fields fallbacks
6
+
3
7
  ## 1.1.0
4
8
 
5
9
  * fixed localized support in combination with SCI
@@ -31,9 +31,22 @@ module Elasticsearch
31
31
  fields.select { |_, field| field.localized? }.each do |name, field|
32
32
  aliased_name = field.options[:as].to_s
33
33
  translations_field_name = [name, 'translations'].join('_')
34
- if obj.key?(name) then obj[name] = send(translations_field_name)
35
- elsif obj.key?(aliased_name) then obj[aliased_name] = send(translations_field_name)
34
+ field_obj = send(translations_field_name)
35
+ field_key = aliased_name.presence || name
36
+
37
+ obj[field_key] = I18n.available_locales.each_with_object({}) do |locale, res|
38
+ res[locale.to_s] = field_obj[locale.to_s].presence || field_obj[locale]
39
+
40
+ next if res[locale].present?
41
+
42
+ if field.send(:fallbacks?) && ::I18n.respond_to?(:fallbacks)
43
+ next unless fallbacks_for_locale = ::I18n.fallbacks[locale]
44
+ next unless fallback_locale = fallbacks_for_locale.map(&:to_s).find{ |loc| field_obj.has_key?(loc) && field_obj[loc].present? }
45
+ res[locale.to_s] = field_obj[fallback_locale]
46
+ end
36
47
  end
48
+
49
+ obj
37
50
  end
38
51
  end
39
52
  end
@@ -1,7 +1,7 @@
1
1
  module Elasticsearch
2
2
  module Model
3
3
  module MongoidExtensions
4
- VERSION = '1.1.0'.freeze
4
+ VERSION = '1.1.1'.freeze
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticsearch-model-mongoid_extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Celizna
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-10 00:00:00.000000000 Z
11
+ date: 2018-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport