dry-elastic_model 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +12 -11
- data/README.md +5 -0
- data/VERSION +1 -1
- data/lib/dry/elastic_model/attributes.rb +33 -4
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f5a0bfc8a861e664e3961981036d4651e3cea94d7ca497902b201d2948c855f
|
4
|
+
data.tar.gz: b11c2fb230d30ee0cd3dcfb8cf27f7d31abf6737ab674e299cf60a7394dbc15a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a25156ba357c9f3e3bcbc8c74a3513ccb9e66b5334b057e170f157ed5125c7d3aa2905a23e539379689044867497eefc477dd4267e9e518e6cc89f5a10c20b8e
|
7
|
+
data.tar.gz: ea0b2b507988ab6e7d507142dc850a3a8265a1ea2b460f0ab364f315bce9e7c05970625330476508358fd009cb432047504551b594adf83b6985c23c18c21e85
|
data/Gemfile.lock
CHANGED
@@ -1,19 +1,20 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
dry-elastic_model (0.
|
4
|
+
dry-elastic_model (0.3.0)
|
5
5
|
dry-struct (~> 1.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
10
|
coderay (1.1.2)
|
11
|
-
concurrent-ruby (1.1.
|
11
|
+
concurrent-ruby (1.1.6)
|
12
12
|
diff-lcs (1.3)
|
13
13
|
docile (1.3.1)
|
14
|
-
dry-configurable (0.
|
14
|
+
dry-configurable (0.11.5)
|
15
15
|
concurrent-ruby (~> 1.0)
|
16
16
|
dry-core (~> 0.4, >= 0.4.7)
|
17
|
+
dry-equalizer (~> 0.2)
|
17
18
|
dry-container (0.7.2)
|
18
19
|
concurrent-ruby (~> 1.0)
|
19
20
|
dry-configurable (~> 0.1, >= 0.1.3)
|
@@ -21,20 +22,20 @@ GEM
|
|
21
22
|
concurrent-ruby (~> 1.0)
|
22
23
|
dry-equalizer (0.3.0)
|
23
24
|
dry-inflector (0.2.0)
|
24
|
-
dry-logic (1.0.
|
25
|
+
dry-logic (1.0.6)
|
25
26
|
concurrent-ruby (~> 1.0)
|
26
27
|
dry-core (~> 0.2)
|
27
28
|
dry-equalizer (~> 0.2)
|
28
|
-
dry-struct (1.
|
29
|
-
dry-core (~> 0.4, >= 0.4.
|
30
|
-
dry-equalizer (~> 0.
|
31
|
-
dry-types (~> 1.
|
29
|
+
dry-struct (1.3.0)
|
30
|
+
dry-core (~> 0.4, >= 0.4.4)
|
31
|
+
dry-equalizer (~> 0.3)
|
32
|
+
dry-types (~> 1.3)
|
32
33
|
ice_nine (~> 0.11)
|
33
|
-
dry-types (1.
|
34
|
+
dry-types (1.4.0)
|
34
35
|
concurrent-ruby (~> 1.0)
|
35
36
|
dry-container (~> 0.3)
|
36
37
|
dry-core (~> 0.4, >= 0.4.4)
|
37
|
-
dry-equalizer (~> 0.
|
38
|
+
dry-equalizer (~> 0.3)
|
38
39
|
dry-inflector (~> 0.1, >= 0.1.2)
|
39
40
|
dry-logic (~> 1.0, >= 1.0.2)
|
40
41
|
ice_nine (0.11.2)
|
@@ -77,4 +78,4 @@ DEPENDENCIES
|
|
77
78
|
simplecov-lcov (~> 0)
|
78
79
|
|
79
80
|
BUNDLED WITH
|
80
|
-
2.
|
81
|
+
2.1.4
|
data/README.md
CHANGED
@@ -37,6 +37,7 @@ Sample model:
|
|
37
37
|
```ruby
|
38
38
|
class FooBar < Dry::ElasticModel::Base
|
39
39
|
field :text_field, :text
|
40
|
+
field :newly_added_text_field, :text, allow_missing: true
|
40
41
|
field :keyword_field, :keyword, index: false
|
41
42
|
field :date_field, :date
|
42
43
|
field :long_field, :long
|
@@ -58,6 +59,10 @@ This corresponds to following Elasticsearch mapping (calling `Foo.mapping.to_jso
|
|
58
59
|
"type": "text",
|
59
60
|
"index": "not_analyzed"
|
60
61
|
},
|
62
|
+
"newly_added_text_field": {
|
63
|
+
"type": "text",
|
64
|
+
"index": "not_analyzed"
|
65
|
+
},
|
61
66
|
"keyword_field": {
|
62
67
|
"type": "keyword",
|
63
68
|
"index": false
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
@@ -4,6 +4,7 @@ module Dry
|
|
4
4
|
module ElasticModel
|
5
5
|
module Attributes
|
6
6
|
def field(name, type, opts = {})
|
7
|
+
allow_missing = opts.delete(:allow_missing)
|
7
8
|
type_definition = Types::TYPES.fetch(type.to_sym)
|
8
9
|
|
9
10
|
type_options_klass = type_definition.meta[:type_options]
|
@@ -15,26 +16,54 @@ module Dry
|
|
15
16
|
end
|
16
17
|
|
17
18
|
default_opts = type_definition.meta[:opts] || {}
|
18
|
-
|
19
|
-
|
19
|
+
define_attribute(
|
20
|
+
name,
|
21
|
+
type_definition.meta(opts: default_opts.merge(options.to_h)),
|
22
|
+
allow_missing: allow_missing
|
23
|
+
)
|
20
24
|
end
|
21
25
|
|
22
26
|
def range(name, type, opts = {})
|
27
|
+
allow_missing = allow_missing
|
23
28
|
member = Types::RANGE_TYPES.fetch(type.to_sym)
|
24
29
|
|
25
30
|
type_definition = Types::Range.call(member)
|
26
31
|
|
27
32
|
default_opts = type_definition.meta[:opts] || {}
|
28
|
-
|
33
|
+
define_attribute(
|
34
|
+
name,
|
35
|
+
type_definition.meta(opts: default_opts.merge(opts)),
|
36
|
+
allow_missing: opts[:allow_missing]
|
37
|
+
)
|
29
38
|
end
|
30
39
|
|
31
40
|
def list(name, type, opts = {})
|
41
|
+
allow_missing = opts.delete(:allow_missing)
|
32
42
|
member = Types::TYPES.fetch(type.to_sym)
|
33
43
|
|
34
44
|
type_definition = Types::Array.call(member)
|
35
45
|
|
36
46
|
default_opts = type_definition.meta[:opts] || {}
|
37
|
-
|
47
|
+
define_attribute(
|
48
|
+
name,
|
49
|
+
type_definition.meta(opts: default_opts.merge(opts)),
|
50
|
+
allow_missing: allow_missing
|
51
|
+
)
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def define_attribute(name, type_definition, allow_missing:)
|
57
|
+
public_send(
|
58
|
+
attr_definition_method(allow_missing),
|
59
|
+
name,
|
60
|
+
type_definition
|
61
|
+
)
|
62
|
+
end
|
63
|
+
|
64
|
+
def attr_definition_method(allow_missing)
|
65
|
+
allow_missing = false if allow_missing.nil?
|
66
|
+
allow_missing ? :attribute? : :attribute
|
38
67
|
end
|
39
68
|
end
|
40
69
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-elastic_model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Konrad Oleksiuk
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-struct
|
@@ -168,8 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
168
|
- !ruby/object:Gem::Version
|
169
169
|
version: '0'
|
170
170
|
requirements: []
|
171
|
-
|
172
|
-
rubygems_version: 2.7.3
|
171
|
+
rubygems_version: 3.1.2
|
173
172
|
signing_key:
|
174
173
|
specification_version: 4
|
175
174
|
summary: Create Elasticsearch models and mappings from code.
|