simply_stored 0.6.4 → 0.6.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/simply_stored/instance_methods.rb +21 -3
- data/lib/simply_stored.rb +1 -1
- metadata +3 -3
@@ -16,13 +16,17 @@ module SimplyStored
|
|
16
16
|
|
17
17
|
def save(validate = true)
|
18
18
|
retry_on_conflict do
|
19
|
-
|
19
|
+
retry_on_connection_error do
|
20
|
+
CouchPotato.database.save_document(self, validate)
|
21
|
+
end
|
20
22
|
end
|
21
23
|
end
|
22
24
|
|
23
25
|
def save!
|
24
26
|
retry_on_conflict do
|
25
|
-
|
27
|
+
retry_on_connection_error do
|
28
|
+
CouchPotato.database.save_document!(self)
|
29
|
+
end
|
26
30
|
end
|
27
31
|
end
|
28
32
|
|
@@ -73,7 +77,21 @@ module SimplyStored
|
|
73
77
|
end
|
74
78
|
|
75
79
|
protected
|
76
|
-
|
80
|
+
|
81
|
+
def retry_on_connection_error(max_retries = 2, &blk)
|
82
|
+
retry_count = 0
|
83
|
+
begin
|
84
|
+
blk.call
|
85
|
+
rescue Errno::ECONNREFUSED => e
|
86
|
+
if retry_count < max_retries
|
87
|
+
retry_count += 1
|
88
|
+
retry
|
89
|
+
else
|
90
|
+
raise e
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
77
95
|
def retry_on_conflict(max_retries = 2, &blk)
|
78
96
|
retry_count = 0
|
79
97
|
begin
|
data/lib/simply_stored.rb
CHANGED
@@ -5,7 +5,7 @@ unless defined?(SimplyStored)
|
|
5
5
|
require File.expand_path(File.dirname(__FILE__) + '/simply_stored/class_methods_base')
|
6
6
|
|
7
7
|
module SimplyStored
|
8
|
-
VERSION = '0.6.
|
8
|
+
VERSION = '0.6.5'
|
9
9
|
class Error < RuntimeError; end
|
10
10
|
class RecordNotFound < RuntimeError; end
|
11
11
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simply_stored
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 5
|
10
|
+
version: 0.6.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Mathias Meyer, Jonathan Weiss
|