elos 1.0.23 → 1.0.24
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 +4 -4
- data/lib/elos/index/attributes/keys_guesser.rb +5 -0
- data/lib/elos/index/attributes.rb +7 -1
- data/lib/elos/index/mappings/generator.rb +14 -0
- data/lib/elos/index/mappings.rb +7 -14
- data/lib/elos/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80382b0017ffa0a395fe35b6de528b0339ec8d27
|
4
|
+
data.tar.gz: cdddbe3449d25388913a6b2561ae82ea351f835c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3cfc4e04e08d71f0b38692e4a43ebab7e0546cf14a0eaf1be58348e3497d5d09b4e77a2d4d180dc03cbe4a93b0fc2cd711a183e42961aa9ff70746fc9ad39eb
|
7
|
+
data.tar.gz: a66163a35fc1b7127a23e49dc42c0571b249bf8ac1fd3cce6c42c5c116219a9e15c6a3c25c7cfa90f43c60c8ad5f3b0217443d2df8ad0bd4539678e6d28d4e8e
|
@@ -2,6 +2,12 @@ module Elos::Index::Attributes
|
|
2
2
|
extend ActiveSupport::Concern
|
3
3
|
|
4
4
|
included do
|
5
|
-
cattr_accessor :
|
5
|
+
cattr_accessor :set_attribute_keys
|
6
|
+
end
|
7
|
+
|
8
|
+
class_methods do
|
9
|
+
def attribute_keys
|
10
|
+
self.set_attribute_keys ||= KeysGuesser.guess(given_mappings, mappings_fields)
|
11
|
+
end
|
6
12
|
end
|
7
13
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class Elos::Index::Mappings::Generator
|
2
|
+
include Elos::Index::Properties
|
3
|
+
|
4
|
+
def self.generate(mappings, fields:, physically_destroyable:, type_name:)
|
5
|
+
fields ||= {}
|
6
|
+
mappings = (mappings || {}).deep_dup
|
7
|
+
mappings[:_all] = { enabled: false } unless mappings[:_all]
|
8
|
+
properties = mappings[:properties] || {}
|
9
|
+
properties[:_destroyed] = boolean_property unless physically_destroyable
|
10
|
+
properties[:json] = no_index_string_property
|
11
|
+
properties.reverse_merge!(fields)
|
12
|
+
{ type_name => mappings }
|
13
|
+
end
|
14
|
+
end
|
data/lib/elos/index/mappings.rb
CHANGED
@@ -2,25 +2,18 @@ module Elos::Index::Mappings
|
|
2
2
|
extend ActiveSupport::Concern
|
3
3
|
|
4
4
|
included do
|
5
|
-
|
5
|
+
cattr_accessor :given_mappings, :set_mappings, :mappings_fields
|
6
6
|
end
|
7
7
|
|
8
8
|
class_methods do
|
9
|
-
def
|
10
|
-
|
11
|
-
|
12
|
-
else
|
13
|
-
self.class_variable_get(:@@mappings)
|
14
|
-
end
|
9
|
+
def field(name, type)
|
10
|
+
self.mappings_fields ||= {}
|
11
|
+
mappings_fields[name] = send("#{type}_property")
|
15
12
|
end
|
16
13
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
mps = mappings.is_a?(Proc) ? mappings.() : mappings.deep_dup
|
21
|
-
self.attribute_keys = %i(id) + mps[:properties].keys
|
22
|
-
mps[:properties].merge!(_destroyed: boolean_property, json: no_index_string_property) if respond_to?(:physically_destroy?) && physically_destroy?
|
23
|
-
self.mappings = { type_name => mps }
|
14
|
+
def mappings(mappings = nil)
|
15
|
+
return self.given_mappings = mappings.is_a?(Proc) ? mappings.() : mappings.deep_dup if mappings
|
16
|
+
self.set_mappings ||= Generator.generate(given_mappings, fields: mappings_fields, type_name: type_name, physically_destroyable: respond_to?(:physically_destroy?) && physically_destroy?)
|
24
17
|
end
|
25
18
|
end
|
26
19
|
end
|
data/lib/elos/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elos
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.24
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tetsuri Moriya
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -151,10 +151,12 @@ files:
|
|
151
151
|
- lib/elos/helpers.rb
|
152
152
|
- lib/elos/index.rb
|
153
153
|
- lib/elos/index/attributes.rb
|
154
|
+
- lib/elos/index/attributes/keys_guesser.rb
|
154
155
|
- lib/elos/index/core.rb
|
155
156
|
- lib/elos/index/indexable.rb
|
156
157
|
- lib/elos/index/locatable.rb
|
157
158
|
- lib/elos/index/mappings.rb
|
159
|
+
- lib/elos/index/mappings/generator.rb
|
158
160
|
- lib/elos/index/model.rb
|
159
161
|
- lib/elos/index/model/assignable.rb
|
160
162
|
- lib/elos/index/model/attributes.rb
|