elasticsearch-model-mongoid_extensions 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bff3160ee99ace6e3189b086c28860d85b6e5e199d5b94c221198d2d125fc9fa
|
4
|
+
data.tar.gz: 6cfe79f4e4697bb67abdacd1b9070038beebd43cebce76bcf55d0d3879b20389
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb092fde421904554da329f4dd18fbddbbd7e2d9cbd87ee05b0a25ddb25b93d7c1c440131378ffaba53c7000169f5fbb044e8ac36e1bb5417be46f46c069cd46
|
7
|
+
data.tar.gz: bb99f9c27ea8d2dbc4142f7903aa77b3c3557ee600d63e32986d9093ed3141997e28648ba05defbe1bdfeaab2a42d2db1ad7bcee4b221f449bf7c40a39b2b917
|
data/CHANGELOG.md
CHANGED
@@ -6,22 +6,22 @@ module Elasticsearch
|
|
6
6
|
module Localized
|
7
7
|
extend ActiveSupport::Concern
|
8
8
|
|
9
|
-
class
|
10
|
-
def
|
11
|
-
|
12
|
-
|
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
|
-
|
21
|
-
|
22
|
-
|
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__.
|
45
|
-
|
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
|
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
|
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-
|
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.
|
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
|