elasticsearch-rails-dynamic-json-support 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/elasticsearch-rails-dynamic-json-support.gemspec +3 -3
- data/lib/elasticsearch/model/indexing_decorator.rb +2 -2
- data/spec/cascade_update_spec.rb +20 -1
- data/spec/db.rb +3 -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: fe860b9480e7641fdbc37cbfe277d74711d09bf1
|
4
|
+
data.tar.gz: 89c418f859ae3655cf211fcee5e08243b936b85b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fdf55972b55e9b58318f3c93bc166898e0cda08d310376cb4b029dd7e728aff59ccba3a83d50fee600c7913511d711634c9c13f3d4c6153bcd86af1b13c1be4
|
7
|
+
data.tar.gz: 4bce5020b172490d3a0a41db30af6f843ee668656e909e6c30a850851b85588cd90fbf02226e56abba5dc891518866f547023a2fa3b99e5850998db2a7719042
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.11
|
@@ -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.11 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.11"
|
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-10-
|
14
|
+
s.date = "2016-10-14"
|
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 = [
|
@@ -21,8 +21,8 @@ module Elasticsearch
|
|
21
21
|
private
|
22
22
|
def _should_pass_to_es
|
23
23
|
tclz = target.class
|
24
|
-
return true unless tclz.
|
25
|
-
condition_blk = tclz.
|
24
|
+
return true unless tclz.instance_variable_defined?(:@_es_condition_block)
|
25
|
+
condition_blk = tclz.instance_variable_get :@_es_condition_block
|
26
26
|
!condition_blk || condition_blk[self]
|
27
27
|
end
|
28
28
|
end
|
data/spec/cascade_update_spec.rb
CHANGED
@@ -121,7 +121,7 @@ RSpec.describe Elasticsearch::Model::CascadeUpdate, type: :model do
|
|
121
121
|
before do
|
122
122
|
@clz.class_eval do
|
123
123
|
es_register_attrs :title
|
124
|
-
es_register_assoc(:reviews, reverse_relationship: 'article',
|
124
|
+
es_register_assoc(:reviews, reverse_relationship: 'article',
|
125
125
|
reverse_trigger: lambda {|review, changes| changes.has_key? :content }
|
126
126
|
) do |review|
|
127
127
|
review.as_json(only: [:content])
|
@@ -166,4 +166,23 @@ RSpec.describe Elasticsearch::Model::CascadeUpdate, type: :model do
|
|
166
166
|
end
|
167
167
|
end
|
168
168
|
end
|
169
|
+
|
170
|
+
context 'searchable' do
|
171
|
+
before do
|
172
|
+
@clz.class_eval do
|
173
|
+
es_register_attrs :title
|
174
|
+
es_to_json_when(:searchable) {|record| record.is_searchable }
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
|
179
|
+
it 'not send to es upon creation & update' do
|
180
|
+
@article = @clz.new title: 'oops', content: 'OooPs', is_searchable: false
|
181
|
+
expect(@article.__elasticsearch__).to receive(:update_document_attributes).never
|
182
|
+
@article.save!
|
183
|
+
@article.update(title: 'is changed')
|
184
|
+
end
|
185
|
+
|
186
|
+
end
|
187
|
+
|
169
188
|
end
|
data/spec/db.rb
CHANGED
@@ -7,6 +7,7 @@ ActiveRecord::Schema.define(version: 1) do
|
|
7
7
|
create_table :articles do |t|
|
8
8
|
t.string :title, null: false
|
9
9
|
t.string :content, null: false
|
10
|
+
t.boolean :is_searchable, null: false, default: true
|
10
11
|
end
|
11
12
|
|
12
13
|
create_table :reviews do |t|
|
@@ -19,6 +20,8 @@ ActiveRecord::Schema.define(version: 1) do
|
|
19
20
|
end
|
20
21
|
|
21
22
|
class Article < ActiveRecord::Base
|
23
|
+
scope :searchable, -> { where(is_searchable: true) }
|
24
|
+
|
22
25
|
validates_presence_of :title
|
23
26
|
validates_presence_of :content
|
24
27
|
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.11
|
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-10-
|
11
|
+
date: 2016-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: elasticsearch-model
|