added database.bulk_delete as an alias for #bulk_save, added support for Model.by_view_name in ExtendedDoc and bumped the version to 0.13.3
This commit is contained in:
parent
3c01875ce5
commit
c4cce18389
8 changed files with 20 additions and 10 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
Gem::Specification.new do |s|
|
||||
s.name = %q{couchrest}
|
||||
s.version = "0.13.2"
|
||||
s.version = "0.13.3"
|
||||
|
||||
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
||||
s.authors = ["J. Chris Anderson", "Matt Aimonetti"]
|
||||
|
|
|
@ -27,7 +27,7 @@ require 'couchrest/monkeypatches'
|
|||
|
||||
# = CouchDB, close to the metal
|
||||
module CouchRest
|
||||
VERSION = '0.13.2'
|
||||
VERSION = '0.13.3'
|
||||
|
||||
autoload :Server, 'couchrest/core/server'
|
||||
autoload :Database, 'couchrest/core/database'
|
||||
|
|
|
@ -90,9 +90,7 @@ module CouchRest
|
|||
def fetch_attachment(doc, name)
|
||||
# slug = escape_docid(docid)
|
||||
# name = CGI.escape(name)
|
||||
|
||||
uri = uri_for_attachment(doc, name)
|
||||
|
||||
RestClient.get uri
|
||||
# "#{@uri}/#{slug}/#{name}"
|
||||
end
|
||||
|
@ -177,6 +175,7 @@ module CouchRest
|
|||
end
|
||||
CouchRest.post "#{@uri}/_bulk_docs", {:docs => docs}
|
||||
end
|
||||
alias :bulk_delete :bulk_save
|
||||
|
||||
# DELETE the document from CouchDB that has the given <tt>_id</tt> and
|
||||
# <tt>_rev</tt>.
|
||||
|
|
|
@ -16,7 +16,7 @@ module CouchRest
|
|||
unless design_doc_fresh
|
||||
refresh_design_doc
|
||||
end
|
||||
view :all, opts, &block
|
||||
view(:all, opts, &block)
|
||||
end
|
||||
|
||||
# Load the first document that have the "couchrest-type" field equal to
|
||||
|
|
|
@ -65,7 +65,7 @@ module CouchRest
|
|||
module ClassMethods
|
||||
|
||||
def property(name, options={})
|
||||
define_property(name, options) unless properties.map{|p| p.name}.include?(name.to_s)
|
||||
define_property(name, options) unless self.properties.map{|p| p.name}.include?(name.to_s)
|
||||
end
|
||||
|
||||
protected
|
||||
|
|
|
@ -95,7 +95,7 @@ module CouchRest
|
|||
end
|
||||
|
||||
# Dispatches to any named view.
|
||||
def view name, query={}, &block
|
||||
def view(name, query={}, &block)
|
||||
unless design_doc_fresh
|
||||
refresh_design_doc
|
||||
end
|
||||
|
@ -128,9 +128,9 @@ module CouchRest
|
|||
|
||||
private
|
||||
|
||||
def fetch_view_with_docs name, opts, raw=false, &block
|
||||
def fetch_view_with_docs(name, opts, raw=false, &block)
|
||||
if raw
|
||||
fetch_view name, opts, &block
|
||||
fetch_view(name, opts, &block)
|
||||
else
|
||||
begin
|
||||
view = fetch_view name, opts.merge({:include_docs => true}), &block
|
||||
|
@ -138,7 +138,7 @@ module CouchRest
|
|||
rescue
|
||||
# fallback for old versions of couchdb that don't
|
||||
# have include_docs support
|
||||
view = fetch_view name, opts, &block
|
||||
view = fetch_view(name, opts, &block)
|
||||
view['rows'].collect{|r|new(database.get(r['id']))} if view['rows']
|
||||
end
|
||||
end
|
||||
|
|
|
@ -74,6 +74,16 @@ module CouchRest
|
|||
end
|
||||
end
|
||||
|
||||
# Temp solution to make the view_by methods available
|
||||
def self.method_missing(m, *args)
|
||||
if has_view?(m)
|
||||
query = args.shift || {}
|
||||
view(m, query, *args)
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
### instance methods
|
||||
|
||||
# Returns the Class properties
|
||||
|
|
|
@ -72,6 +72,7 @@ describe CouchRest::CastedModel do
|
|||
before(:each) do
|
||||
@obj = DummyModel.new(:casted_attribute => {:name => 'whatever'})
|
||||
@obj.save.should be_true
|
||||
@obj = DummyModel.get(@obj.id)
|
||||
end
|
||||
|
||||
it "should be able to load with the casted models" do
|
||||
|
|
Loading…
Reference in a new issue