elasticsearch-rails-dynamic-json-support 0.0.7 → 0.0.8
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/VERSION +1 -1
- data/elasticsearch-rails-dynamic-json-support.gemspec +3 -3
- data/lib/elasticsearch/model/cascade_update.rb +10 -1
- data/spec/cascade_update_spec.rb +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e70d9c317d5429c2723d409712ad6487cbb4e0a
|
4
|
+
data.tar.gz: 6ad1029a712bb5178f130e9bc4c1e2ed279e1125
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e766296a980d3dea04bc1c3d249f07d229050c73698943a67408a6d356fc545ac9578288448c1e420c42f0dddeca379a9761c97dcdd4df6dab1a553250f44e2
|
7
|
+
data.tar.gz: 12ee402f16e2b9cc10db96c42131a430ce0a5f443233511d2be8756f87f561f9e142be311f2d1eb6618d5a40e137a18ce5d413f2b1d275b04081739c5586c3cc
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.8
|
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: elasticsearch-rails-dynamic-json-support 0.0.
|
5
|
+
# stub: elasticsearch-rails-dynamic-json-support 0.0.8 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "elasticsearch-rails-dynamic-json-support".freeze
|
9
|
-
s.version = "0.0.
|
9
|
+
s.version = "0.0.8"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["Song Yangyu".freeze]
|
14
|
-
s.date = "2016-
|
14
|
+
s.date = "2016-10-04"
|
15
15
|
s.description = "Enhance elasticsearch-rails with `elasticsearch_json_changes` to translate the attribute changes into document updates".freeze
|
16
16
|
s.email = "flyfy1@gmail.com".freeze
|
17
17
|
s.extra_rdoc_files = [
|
@@ -101,7 +101,7 @@ module Elasticsearch
|
|
101
101
|
self.instance_variable_set(:@__changed_attributes__, instance.changes)
|
102
102
|
end
|
103
103
|
|
104
|
-
after_commit do |instance|
|
104
|
+
after_commit on: [:create, :update] do |instance|
|
105
105
|
changes = instance.instance_variable_get(:@__changed_attributes__)
|
106
106
|
|
107
107
|
Array.wrap(self.public_send reverse_relationship).each do |record|
|
@@ -110,6 +110,15 @@ module Elasticsearch
|
|
110
110
|
|
111
111
|
instance.remove_instance_variable(:@__changed_attributes__)
|
112
112
|
end
|
113
|
+
|
114
|
+
after_destroy do |instance|
|
115
|
+
# after destroy would force a re-render
|
116
|
+
Array.wrap(self.public_send reverse_relationship).each do |record|
|
117
|
+
# reload to remove the deleted attrs. TODO: find a proper way
|
118
|
+
record.reload
|
119
|
+
record.es_partial_update(key_name)
|
120
|
+
end
|
121
|
+
end
|
113
122
|
end
|
114
123
|
end
|
115
124
|
|
data/spec/cascade_update_spec.rb
CHANGED
@@ -151,6 +151,18 @@ RSpec.describe Elasticsearch::Model::CascadeUpdate, type: :model do
|
|
151
151
|
@review.save!
|
152
152
|
end
|
153
153
|
end
|
154
|
+
|
155
|
+
describe 'destroy' do
|
156
|
+
it do
|
157
|
+
expect(@article.__elasticsearch__).to receive(:update_document_attributes).with(
|
158
|
+
"reviews"=>[ {"content"=>"review 1"} ]
|
159
|
+
)
|
160
|
+
|
161
|
+
@review = @article.reviews[1]
|
162
|
+
@review.destroy!
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
154
166
|
end
|
155
167
|
end
|
156
168
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elasticsearch-rails-dynamic-json-support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Song Yangyu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: elasticsearch-model
|