elasticsearch-model-mongoid_extensions 1.0.1 → 1.1.0

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: 83ae68f2327ac0a29070798111ed65724b3f14108f55985c9d356a655a3cb742
4
- data.tar.gz: 16392943f8ef6d971a43acc2cfb5672e1d00c387ce9b3d26bde0827241aa7b00
3
+ metadata.gz: bff3160ee99ace6e3189b086c28860d85b6e5e199d5b94c221198d2d125fc9fa
4
+ data.tar.gz: 6cfe79f4e4697bb67abdacd1b9070038beebd43cebce76bcf55d0d3879b20389
5
5
  SHA512:
6
- metadata.gz: 44c88ff3857330feded922b34736b452b8a9a1e5559e2d5bc687e07505b44e51a570fd7e6b7ab07a8395ed5fe2c903f074b559650b1b29a8ff3dd8a2ef5dcc0e
7
- data.tar.gz: 3dbc352f073198c5b741bc555880843a481d1222170021afe549eec41e4bf2a1bbe1a1af4361bf09430ee8352668401e374a9e35934dfe5dd6c3ef691550fd85
6
+ metadata.gz: eb092fde421904554da329f4dd18fbddbbd7e2d9cbd87ee05b0a25ddb25b93d7c1c440131378ffaba53c7000169f5fbb044e8ac36e1bb5417be46f46c069cd46
7
+ data.tar.gz: bb99f9c27ea8d2dbc4142f7903aa77b3c3557ee600d63e32986d9093ed3141997e28648ba05defbe1bdfeaab2a42d2db1ad7bcee4b221f449bf7c40a39b2b917
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.1.0
4
+
5
+ * fixed localized support in combination with SCI
6
+
3
7
  ## 1.0.1
4
8
 
5
9
  * Mongoid 7 compatibility
@@ -6,22 +6,22 @@ module Elasticsearch
6
6
  module Localized
7
7
  extend ActiveSupport::Concern
8
8
 
9
- class Mappings < Elasticsearch::Model::Indexing::Mappings
10
- def indexes(name, options = {}, &block)
11
- # take the cls from options on the Mappings object
12
- @cls ||= @options.delete(:cls) if @options[:cls]
13
-
14
- return super(name, options, &block) unless @cls
15
-
16
- field = @cls.fields[name.to_s] || @cls.fields.detect { |_, meta| meta.options[:as] == name.to_sym }.try(:last)
17
-
18
- return super(name, options, &block) unless field.present? && field.localized?
9
+ class ProcessMappings < Struct.new(:cls, :mapping)
10
+ def self.call(*args)
11
+ new(*args).call
12
+ end
19
13
 
20
- super(name) do
21
- Array(::I18n.available_locales).each do |locale|
22
- super(locale, options, &block)
14
+ def call
15
+ mapping.each do |field_name, options|
16
+ next unless field = cls.fields[field_name.to_s] || cls.fields.detect { |_, meta| meta.options[:as] == field_name.to_sym }.try(:last)
17
+ next unless field.localized?
18
+ next if mapping[field_name]&.frozen?
19
+ mapping[field_name] = ::I18n.available_locales.each_with_object({ type: 'object', properties: {} }) do |locale, res|
20
+ res[:properties][locale] = options.dup
23
21
  end
22
+ mapping[field_name].freeze
24
23
  end
24
+ mapping
25
25
  end
26
26
  end
27
27
 
@@ -41,8 +41,14 @@ module Elasticsearch
41
41
 
42
42
  included do
43
43
  def self.mapping(options = {}, &block)
44
- __elasticsearch__.instance_variable_set(:@mapping, Mappings.new(document_type, { cls: self }.merge(options))) unless __elasticsearch__.instance_variable_get(:@mapping)
45
- __elasticsearch__.mapping(options, &block)
44
+ mappings = __elasticsearch__.mapping(options, &block)
45
+ if mappings.is_a?(Elasticsearch::Model::Indexing::Mappings)
46
+ if mapping = mappings.instance_variable_get(:@mapping)
47
+ updated_mapping = ProcessMappings.call(self, mapping)
48
+ mappings.instance_variable_set(:@mapping, updated_mapping)
49
+ end
50
+ end
51
+ mappings
46
52
  end
47
53
 
48
54
  prepend Serializing
@@ -1,7 +1,7 @@
1
1
  module Elasticsearch
2
2
  module Model
3
3
  module MongoidExtensions
4
- VERSION = '1.0.1'.freeze
4
+ VERSION = '1.1.0'.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.0.1
4
+ version: 1.1.0
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-05-03 00:00:00.000000000 Z
11
+ date: 2018-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -216,7 +216,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
216
216
  version: '0'
217
217
  requirements: []
218
218
  rubyforge_project:
219
- rubygems_version: 2.7.3
219
+ rubygems_version: 2.7.6
220
220
  signing_key:
221
221
  specification_version: 4
222
222
  summary: Elasticsearch::Model extensions for Mongoid adding support of single collection