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: 034ae9bcd714c12863369d793da42c579f118391ac422c3a764ac7d0b47acd41
4
- data.tar.gz: b567f825cac56b3223531b03206338e5b39b438e3a6a1523eafed845a2e9a410
3
+ metadata.gz: 40d0ec9b57158ba7cde955a7e89de398fae1cc40d766444e2955d21c627260cd
4
+ data.tar.gz: 8334cdfef385e392dc2d6dd4484c150e019806c4f96492dd4402cbf3ef15c086
5
5
  SHA512:
6
- metadata.gz: dadbd1bbe20495941ed754c9ffec56181cbf40d69f180d4058f53e6693270bbda611353e4de0246db65ef0eac2a19cc305fff278097bb544825500901d98c94e
7
- data.tar.gz: e924b4b364646ceb7c15095576092043b7053c037c02afd408e58e44dc588d1bcf6a4bf7a80ace08a56ddd1ac298968fdab5bcfc53031c9b188bb30279f7a77c
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(m, *args, &block)
46
- respond_to_missing?(m) ? result['hits']['hits'].send(m, *args, &block) : super
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?(m, include_private = false)
51
- result['hits']['hits'].respond_to?(m, include_private) || super
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
@@ -4,6 +4,6 @@ module Sequel
4
4
  # See https://jrgns.github.io/sequel-elasticsearch
5
5
  module Elasticsearch
6
6
  # The Gem's version.
7
- VERSION = '0.4.5'.freeze
7
+ VERSION = '0.4.6'.freeze
8
8
  end
9
9
  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 { index_document }
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 { destroy_document }
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 { index_document }
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.5
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-10 00:00:00.000000000 Z
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.4
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.