elastic_searchable 0.7.1 → 0.7.2
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.
@@ -16,9 +16,8 @@ module ElasticSearchable
|
|
16
16
|
# :unless (optional) reference symbol/proc condition to skip indexing when condition is true
|
17
17
|
# :json (optional) configure the json document to be indexed (see http://api.rubyonrails.org/classes/ActiveModel/Serializers/JSON.html#method-i-as_json for available options)
|
18
18
|
def elastic_searchable(options = {})
|
19
|
-
options.symbolize_keys!
|
20
19
|
cattr_accessor :elastic_options
|
21
|
-
self.elastic_options = options.merge(:unless => Array.wrap(options[:unless]).push(
|
20
|
+
self.elastic_options = options.symbolize_keys.merge(:unless => Array.wrap(options[:unless]).push(:elasticsearch_offline?))
|
22
21
|
|
23
22
|
extend ElasticSearchable::Indexing::ClassMethods
|
24
23
|
extend ElasticSearchable::Queries
|
data/lib/elastic_searchable.rb
CHANGED
@@ -14,13 +14,13 @@ module ElasticSearchable
|
|
14
14
|
|
15
15
|
# execute a block of work without reindexing objects
|
16
16
|
def offline(&block)
|
17
|
-
offline = true
|
17
|
+
@offline = true
|
18
18
|
yield
|
19
19
|
ensure
|
20
|
-
offline = false
|
20
|
+
@offline = false
|
21
21
|
end
|
22
22
|
def offline?
|
23
|
-
|
23
|
+
!!@offline
|
24
24
|
end
|
25
25
|
# encapsulate encoding hash into json string
|
26
26
|
# support Yajl encoder if installed
|
@@ -82,31 +82,32 @@ class TestElasticSearchable < Test::Unit::TestCase
|
|
82
82
|
should 'not have fired after_index_on_update callback' do
|
83
83
|
assert !@post.indexed_on_update?
|
84
84
|
end
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
85
|
+
end
|
86
|
+
|
87
|
+
context 'Model.update' do
|
88
|
+
setup do
|
89
|
+
Post.create :title => 'foo', :body => 'bar'
|
90
|
+
@post = Post.last
|
91
|
+
@post.title = 'baz'
|
92
|
+
@post.save
|
93
|
+
end
|
94
|
+
should 'have fired after_index callback' do
|
95
|
+
assert @post.indexed?
|
96
|
+
end
|
97
|
+
should 'not have fired after_index_on_create callback' do
|
98
|
+
assert !@post.indexed_on_create?
|
99
|
+
end
|
100
|
+
should 'have fired after_index_on_update callback' do
|
101
|
+
assert @post.indexed_on_update?
|
99
102
|
end
|
100
103
|
end
|
101
104
|
|
102
105
|
context 'Model.create within ElasticSearchable.offline block' do
|
103
106
|
setup do
|
104
|
-
Post.any_instance.expects(:update_index_on_create).never
|
105
107
|
ElasticSearchable.offline do
|
106
108
|
@post = Post.create :title => 'foo', :body => "bar"
|
107
109
|
end
|
108
110
|
end
|
109
|
-
should 'not have triggered indexing behavior' do end #see expectations
|
110
111
|
should 'not have fired after_index callback' do
|
111
112
|
assert !@post.indexed?
|
112
113
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elastic_searchable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
|
-
-
|
10
|
-
version: 0.7.
|
9
|
+
- 2
|
10
|
+
version: 0.7.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ryan Sonnek
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-04
|
18
|
+
date: 2011-05-04 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: activerecord
|