mattetti-couchrest 0.26 → 0.27
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.
- data/lib/couchrest.rb +2 -2
- data/lib/couchrest/mixins/design_doc.rb +10 -5
- metadata +1 -1
data/lib/couchrest.rb
CHANGED
@@ -16,7 +16,7 @@ require 'rubygems'
|
|
16
16
|
begin
|
17
17
|
require 'json'
|
18
18
|
rescue LoadError
|
19
|
-
raise "You need install and require your own compatible
|
19
|
+
raise "You need install and require your own json compatible library since couchrest rest couldn't load the json/json_pure gem" unless Kernel.const_defined?("JSON")
|
20
20
|
end
|
21
21
|
require 'rest_client'
|
22
22
|
|
@@ -30,7 +30,7 @@ require 'couchrest/monkeypatches'
|
|
30
30
|
|
31
31
|
# = CouchDB, close to the metal
|
32
32
|
module CouchRest
|
33
|
-
VERSION = '0.
|
33
|
+
VERSION = '0.27' unless self.const_defined?("VERSION")
|
34
34
|
|
35
35
|
autoload :Server, 'couchrest/core/server'
|
36
36
|
autoload :Database, 'couchrest/core/database'
|
@@ -44,16 +44,14 @@ module CouchRest
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def refresh_design_doc
|
47
|
-
|
48
|
-
|
49
|
-
#design_doc.database = nil
|
50
|
-
self.design_doc_fresh = true
|
47
|
+
reset_design_doc
|
48
|
+
save_design_doc
|
51
49
|
end
|
52
50
|
|
53
51
|
# Save the design doc onto the default database, and update the
|
54
52
|
# design_doc attribute
|
55
53
|
def save_design_doc
|
56
|
-
|
54
|
+
reset_design_doc unless design_doc_fresh
|
57
55
|
self.design_doc = update_design_doc(design_doc)
|
58
56
|
end
|
59
57
|
|
@@ -64,6 +62,13 @@ module CouchRest
|
|
64
62
|
end
|
65
63
|
|
66
64
|
private
|
65
|
+
|
66
|
+
def reset_design_doc
|
67
|
+
design_doc['_id'] = design_doc_id
|
68
|
+
design_doc.delete('_rev')
|
69
|
+
#design_doc.database = nil
|
70
|
+
self.design_doc_fresh = true
|
71
|
+
end
|
67
72
|
|
68
73
|
# Writes out a design_doc to a given database, returning the
|
69
74
|
# updated design doc
|