mattetti-couchrest 0.13.2 → 0.13.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/couchrest/core/database.rb +1 -2
- data/lib/couchrest/mixins/document_queries.rb +1 -1
- data/lib/couchrest/mixins/properties.rb +1 -1
- data/lib/couchrest/mixins/views.rb +4 -4
- data/lib/couchrest/more/extended_document.rb +10 -0
- data/lib/couchrest.rb +1 -1
- data/spec/couchrest/more/casted_model_spec.rb +1 -0
- metadata +1 -1
@@ -90,9 +90,7 @@ module CouchRest
|
|
90
90
|
def fetch_attachment(doc, name)
|
91
91
|
# slug = escape_docid(docid)
|
92
92
|
# name = CGI.escape(name)
|
93
|
-
|
94
93
|
uri = uri_for_attachment(doc, name)
|
95
|
-
|
96
94
|
RestClient.get uri
|
97
95
|
# "#{@uri}/#{slug}/#{name}"
|
98
96
|
end
|
@@ -177,6 +175,7 @@ module CouchRest
|
|
177
175
|
end
|
178
176
|
CouchRest.post "#{@uri}/_bulk_docs", {:docs => docs}
|
179
177
|
end
|
178
|
+
alias :bulk_delete :bulk_save
|
180
179
|
|
181
180
|
# DELETE the document from CouchDB that has the given <tt>_id</tt> and
|
182
181
|
# <tt>_rev</tt>.
|
@@ -65,7 +65,7 @@ module CouchRest
|
|
65
65
|
module ClassMethods
|
66
66
|
|
67
67
|
def property(name, options={})
|
68
|
-
define_property(name, options) unless properties.map{|p| p.name}.include?(name.to_s)
|
68
|
+
define_property(name, options) unless self.properties.map{|p| p.name}.include?(name.to_s)
|
69
69
|
end
|
70
70
|
|
71
71
|
protected
|
@@ -95,7 +95,7 @@ module CouchRest
|
|
95
95
|
end
|
96
96
|
|
97
97
|
# Dispatches to any named view.
|
98
|
-
def view
|
98
|
+
def view(name, query={}, &block)
|
99
99
|
unless design_doc_fresh
|
100
100
|
refresh_design_doc
|
101
101
|
end
|
@@ -128,9 +128,9 @@ module CouchRest
|
|
128
128
|
|
129
129
|
private
|
130
130
|
|
131
|
-
def fetch_view_with_docs
|
131
|
+
def fetch_view_with_docs(name, opts, raw=false, &block)
|
132
132
|
if raw
|
133
|
-
fetch_view
|
133
|
+
fetch_view(name, opts, &block)
|
134
134
|
else
|
135
135
|
begin
|
136
136
|
view = fetch_view name, opts.merge({:include_docs => true}), &block
|
@@ -138,7 +138,7 @@ module CouchRest
|
|
138
138
|
rescue
|
139
139
|
# fallback for old versions of couchdb that don't
|
140
140
|
# have include_docs support
|
141
|
-
view = fetch_view
|
141
|
+
view = fetch_view(name, opts, &block)
|
142
142
|
view['rows'].collect{|r|new(database.get(r['id']))} if view['rows']
|
143
143
|
end
|
144
144
|
end
|
@@ -74,6 +74,16 @@ module CouchRest
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
+
# Temp solution to make the view_by methods available
|
78
|
+
def self.method_missing(m, *args)
|
79
|
+
if has_view?(m)
|
80
|
+
query = args.shift || {}
|
81
|
+
view(m, query, *args)
|
82
|
+
else
|
83
|
+
super
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
77
87
|
### instance methods
|
78
88
|
|
79
89
|
# Returns the Class properties
|
data/lib/couchrest.rb
CHANGED