index-tanked 0.1.11 → 0.1.12
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.
@@ -5,10 +5,25 @@ module IndexTanked
|
|
5
5
|
@index_tanked ||= InstanceCompanion.new(self)
|
6
6
|
end
|
7
7
|
|
8
|
-
def add_to_index_tank
|
9
|
-
self.class.add_to_index_tank(index_tanked.doc_id, index_tanked.data)
|
8
|
+
def add_to_index_tank(fallback=true)
|
9
|
+
self.class.add_to_index_tank(index_tanked.doc_id, index_tanked.data, fallback)
|
10
10
|
ancestor = self.class._ancestors_to_index.first
|
11
|
-
self.becomes(ancestor).add_to_index_tank if ancestor
|
11
|
+
self.becomes(ancestor).add_to_index_tank(fallback) if ancestor
|
12
|
+
end
|
13
|
+
|
14
|
+
def add_to_index_tank_after_save(fallback=true)
|
15
|
+
if index_tanked.dependencies_changed?
|
16
|
+
add_to_index_tank(fallback)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def delete_from_index_tank_after_destroy
|
21
|
+
doc_ids = []
|
22
|
+
doc_ids << index_tanked.doc_id
|
23
|
+
self.class._ancestors_to_index.each do |ancestor|
|
24
|
+
doc_ids << becomes(ancestor).index_tanked.doc_id
|
25
|
+
end
|
26
|
+
self.class.delete_doc_ids_from_index_tank(doc_ids.compact)
|
12
27
|
end
|
13
28
|
end
|
14
29
|
end
|
@@ -19,7 +19,7 @@ module IndexTanked
|
|
19
19
|
else
|
20
20
|
IndexTanked::Configuration.timeout
|
21
21
|
end
|
22
|
-
if timeout
|
22
|
+
if timeout && fallback
|
23
23
|
IndexTanked::Timer.timeout(timeout, TimeoutExceededError) do
|
24
24
|
sleep(timeout + 1) if $testing_index_tanked_timeout
|
25
25
|
@index_tanked.index.document(doc_id).add(*data)
|
@@ -51,7 +51,7 @@ module IndexTanked
|
|
51
51
|
else
|
52
52
|
IndexTanked::Configuration.timeout
|
53
53
|
end
|
54
|
-
if timeout
|
54
|
+
if timeout && fallback
|
55
55
|
IndexTanked::Timer.timeout(timeout, TimeoutExceededError) do
|
56
56
|
sleep(timeout + 1) if $testing_index_tanked_timeout
|
57
57
|
@index_tanked.index.document(doc_id).delete
|
@@ -27,20 +27,9 @@ module IndexTanked
|
|
27
27
|
a != self && a != ActiveRecord::Base && a.ancestors.include?(ActiveRecord::Base) && !a.abstract_class?
|
28
28
|
}
|
29
29
|
|
30
|
-
after_save
|
31
|
-
if instance.index_tanked.dependencies_changed?
|
32
|
-
instance.add_to_index_tank
|
33
|
-
end
|
34
|
-
end
|
30
|
+
after_save :add_to_index_tank_after_save
|
35
31
|
|
36
|
-
after_destroy
|
37
|
-
doc_id = instance.index_tanked.doc_id
|
38
|
-
instance.class.delete_from_index_tank(doc_id)
|
39
|
-
instance.class._ancestors_to_index.each do |ancestor|
|
40
|
-
doc_id = instance.index_tanked.doc_id
|
41
|
-
instance.becomes(ancestor).delete_from_index_tank(doc_id)
|
42
|
-
end
|
43
|
-
end
|
32
|
+
after_destroy :delete_from_index_tank_after_destroy
|
44
33
|
end
|
45
34
|
end
|
46
35
|
end
|
data/lib/index-tanked/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: index-tanked
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 3
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 12
|
10
|
+
version: 0.1.12
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Adam Kittelson
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-03-
|
19
|
+
date: 2011-03-29 00:00:00 -05:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|