Adding alias to get for find
This commit is contained in:
parent
c06907fe58
commit
7b40042087
|
@ -56,6 +56,7 @@ module CouchRest
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
alias :find :get
|
||||||
|
|
||||||
# Load a document from the database by id
|
# Load a document from the database by id
|
||||||
# An exception will be raised if the document isn't found
|
# An exception will be raised if the document isn't found
|
||||||
|
@ -72,6 +73,7 @@ module CouchRest
|
||||||
doc = db.get id
|
doc = db.get id
|
||||||
create_from_database(doc)
|
create_from_database(doc)
|
||||||
end
|
end
|
||||||
|
alias :find! :get!
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -328,15 +328,20 @@ describe "ExtendedDocument" do
|
||||||
foundart = Article.get @art.id
|
foundart = Article.get @art.id
|
||||||
foundart.title.should == "All About Getting"
|
foundart.title.should == "All About Getting"
|
||||||
end
|
end
|
||||||
|
it "should load and instantiate with find" do
|
||||||
|
foundart = Article.find @art.id
|
||||||
|
foundart.title.should == "All About Getting"
|
||||||
|
end
|
||||||
it "should return nil if `get` is used and the document doesn't exist" do
|
it "should return nil if `get` is used and the document doesn't exist" do
|
||||||
foundart = Article.get 'matt aimonetti'
|
foundart = Article.get 'matt aimonetti'
|
||||||
foundart.should be_nil
|
foundart.should be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should raise an error if `get!` is used and the document doesn't exist" do
|
it "should raise an error if `get!` is used and the document doesn't exist" do
|
||||||
lambda{foundart = Article.get!('matt aimonetti')}.should raise_error
|
lambda{foundart = Article.get!('matt aimonetti')}.should raise_error
|
||||||
end
|
end
|
||||||
|
it "should raise an error if `find!` is used and the document doesn't exist" do
|
||||||
|
lambda{foundart = Article.find!('matt aimonetti')}.should raise_error
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "getting a model with a subobjects array" do
|
describe "getting a model with a subobjects array" do
|
||||||
|
|
Loading…
Reference in a new issue