sequel-elasticsearch 0.4.5 → 0.4.6
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: 40d0ec9b57158ba7cde955a7e89de398fae1cc40d766444e2955d21c627260cd
|
4
|
+
data.tar.gz: 8334cdfef385e392dc2d6dd4484c150e019806c4f96492dd4402cbf3ef15c086
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21bdfe86e4e4b805d3883a8ae6b40fd4764f0042cfbc70e7e02e5da827c6c0d9953bcb778ef27ca0af6ec5b7ec2fcf6da71f0aed3be7487ac86a3261178a9e4b
|
7
|
+
data.tar.gz: 2d29bcb6942344846e3ffb7cea2fb1fd524c58ecbca4ed36069d50f0dfe6f79ba67967ce86a6232824a0c1c6de4c781dcdc4e2e804304c13e64fe1bc4fb9820a
|
@@ -38,17 +38,18 @@ module Sequel
|
|
38
38
|
# Each implementation for the Enumerable. Yield each element in the +result['hits']['hits']+ array.
|
39
39
|
def each
|
40
40
|
return [] unless result['hits'] && result['hits']['hits'].count.positive?
|
41
|
+
|
41
42
|
result['hits']['hits'].each { |h| yield h }
|
42
43
|
end
|
43
44
|
|
44
45
|
# Send all undefined methods to the +result['hits']['hits']+ array.
|
45
|
-
def method_missing(
|
46
|
-
respond_to_missing?(
|
46
|
+
def method_missing(meth, *args, &block)
|
47
|
+
respond_to_missing?(meth) ? result['hits']['hits'].send(meth, *args, &block) : super
|
47
48
|
end
|
48
49
|
|
49
50
|
# Send all undefined methods to the +result['hits']['hits']+ array.
|
50
|
-
def respond_to_missing?(
|
51
|
-
result['hits']['hits'].respond_to?(
|
51
|
+
def respond_to_missing?(meth, include_private = false)
|
52
|
+
result['hits']['hits'].respond_to?(meth, include_private) || super
|
52
53
|
end
|
53
54
|
|
54
55
|
private
|
@@ -56,6 +57,7 @@ module Sequel
|
|
56
57
|
# Convert an Elasticsearch hit to a Sequel::Model
|
57
58
|
def convert(hit)
|
58
59
|
return hit unless model
|
60
|
+
|
59
61
|
source = hit['_source'].each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
60
62
|
model.call source
|
61
63
|
end
|
@@ -89,21 +89,21 @@ module Sequel
|
|
89
89
|
# It's "safe" in that it won't raise an error if it fails.
|
90
90
|
def after_create
|
91
91
|
super
|
92
|
-
self.class.call_es {
|
92
|
+
self.class.call_es { _index_document }
|
93
93
|
end
|
94
94
|
|
95
95
|
# Sequel::Model after_destroy hook to remove the record from the Elasticsearch index.
|
96
96
|
# It's "safe" in that it won't raise an error if it fails.
|
97
97
|
def after_destroy
|
98
98
|
super
|
99
|
-
self.class.call_es {
|
99
|
+
self.class.call_es { _destroy_document }
|
100
100
|
end
|
101
101
|
|
102
102
|
# Sequel::Model after_update hook to update the record in the Elasticsearch index.
|
103
103
|
# It's "safe" in that it won't raise an error if it fails.
|
104
104
|
def after_update
|
105
105
|
super
|
106
|
-
self.class.call_es {
|
106
|
+
self.class.call_es { _index_document }
|
107
107
|
end
|
108
108
|
|
109
109
|
# Return the Elasticsearch client used to communicate with the cluster.
|
@@ -115,6 +115,12 @@ module Sequel
|
|
115
115
|
indexed_values
|
116
116
|
end
|
117
117
|
|
118
|
+
# Internal reference for index_document. Override this for alternate
|
119
|
+
# implementations of indexing the document.
|
120
|
+
def _index_document
|
121
|
+
index_document
|
122
|
+
end
|
123
|
+
|
118
124
|
# Create or update the document on the Elasticsearch cluster.
|
119
125
|
def index_document
|
120
126
|
params = document_path
|
@@ -122,6 +128,12 @@ module Sequel
|
|
122
128
|
es_client.index params
|
123
129
|
end
|
124
130
|
|
131
|
+
# Internal reference for destroy_document. Override this for alternate
|
132
|
+
# implementations of removing the document.
|
133
|
+
def _destroy_document
|
134
|
+
destroy_document
|
135
|
+
end
|
136
|
+
|
125
137
|
# Remove the document from the Elasticsearch cluster.
|
126
138
|
def destroy_document
|
127
139
|
es_client.delete document_path
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequel-elasticsearch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jurgens du Toit
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07
|
11
|
+
date: 2019-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: elasticsearch
|
@@ -163,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
163
|
- !ruby/object:Gem::Version
|
164
164
|
version: '0'
|
165
165
|
requirements: []
|
166
|
-
rubygems_version: 3.0.
|
166
|
+
rubygems_version: 3.0.6
|
167
167
|
signing_key:
|
168
168
|
specification_version: 4
|
169
169
|
summary: A plugin for the Sequel gem to sync data to Elasticsearch.
|