From ce61a6bd551a96205892a125c8835c4bc69c4fad Mon Sep 17 00:00:00 2001 From: taryn Date: Fri, 21 Aug 2009 09:45:29 +0100 Subject: Added first/last/all aliases for equivalent find scopes Just a copy from Active Record (with tests). Each is a warpper function for the equivalent scoped call to find eg first is a wrapper for find(:first) Signed-off-by: Joshua Peek --- activeresource/lib/active_resource/base.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'activeresource/lib') diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb index f27febb7ef..e5b8589fb3 100644 --- a/activeresource/lib/active_resource/base.rb +++ b/activeresource/lib/active_resource/base.rb @@ -611,6 +611,28 @@ module ActiveResource end end + + # A convenience wrapper for find(:first, *args). You can pass + # in all the same arguments to this method as you can to + # find(:first). + def first(*args) + find(:first, *args) + end + + # A convenience wrapper for find(:last, *args). You can pass + # in all the same arguments to this method as you can to + # find(:last). + def last(*args) + find(:last, *args) + end + + # This is an alias for find(:all). You can pass in all the same + # arguments to this method as you can to find(:all) + def all(*args) + find(:all, *args) + end + + # Deletes the resources with the ID in the +id+ parameter. # # ==== Options -- cgit v1.2.3