From 1c5feaa845dcbdeeca16d760f15384f3e0cda41d Mon Sep 17 00:00:00 2001 From: Matt Aimonetti Date: Mon, 3 Nov 2008 18:08:14 -0800 Subject: [PATCH] added documentation to model#first --- lib/couchrest/core/model.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/couchrest/core/model.rb b/lib/couchrest/core/model.rb index fa3692e..c992b27 100644 --- a/lib/couchrest/core/model.rb +++ b/lib/couchrest/core/model.rb @@ -112,7 +112,7 @@ module CouchRest end # Load all documents that have the "couchrest-type" field equal to the - # name of the current class. Take thes the standard set of + # name of the current class. Take the standard set of # CouchRest::Database#view options. def all opts = {} self.generated_design_doc ||= default_design_doc @@ -124,6 +124,17 @@ module CouchRest fetch_view_with_docs(view_name, opts, raw) end + # Load the first document that have the "couchrest-type" field equal to + # the name of the current class. + # + # ==== Returns + # Object:: The first object instance available + # or + # Nil:: if no instances available + # + # ==== Parameters + # opts:: + # View options, see CouchRest::Database#view options for more info. def first opts = {} first_instance = self.all(opts.merge!(:count => 1)) first_instance.empty? ? nil : first_instance.first