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.
@@ -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>.
@@ -16,7 +16,7 @@ module CouchRest
16
16
  unless design_doc_fresh
17
17
  refresh_design_doc
18
18
  end
19
- view :all, opts, &block
19
+ view(:all, opts, &block)
20
20
  end
21
21
 
22
22
  # Load the first document that have the "couchrest-type" field equal to
@@ -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 name, query={}, &block
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 name, opts, raw=false, &block
131
+ def fetch_view_with_docs(name, opts, raw=false, &block)
132
132
  if raw
133
- fetch_view name, opts, &block
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 name, opts, &block
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
@@ -27,7 +27,7 @@ require 'couchrest/monkeypatches'
27
27
 
28
28
  # = CouchDB, close to the metal
29
29
  module CouchRest
30
- VERSION = '0.13.2'
30
+ VERSION = '0.13.3'
31
31
 
32
32
  autoload :Server, 'couchrest/core/server'
33
33
  autoload :Database, 'couchrest/core/database'
@@ -72,6 +72,7 @@ describe CouchRest::CastedModel do
72
72
  before(:each) do
73
73
  @obj = DummyModel.new(:casted_attribute => {:name => 'whatever'})
74
74
  @obj.save.should be_true
75
+ @obj = DummyModel.get(@obj.id)
75
76
  end
76
77
 
77
78
  it "should be able to load with the casted models" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mattetti-couchrest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.2
4
+ version: 0.13.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - J. Chris Anderson