public
Description: StrokeDB is an embeddable distributed document database written in Ruby
Homepage: http://strokedb.com/
Clone URL: git://github.com/yrashk/strokedb.git
Search Repo:
Added Meta#last as complement to Meta#first.
thewordnerd (author)
Wed Apr 23 14:55:53 -0700 2008
commit  5e354b3da560d855a904191b69bbfb0bcaff7e7a
tree    99048cfb967d885e74fd5fcab8de2b80c76a6c89
parent  9e8d771fb6aee81dbd9f170326e5004f309e0136
...
199
200
201
 
 
 
 
 
 
 
 
202
203
204
...
199
200
201
202
203
204
205
206
207
208
209
210
211
212
0
@@ -199,6 +199,14 @@ module StrokeDB
0
     end
0
 
0
     #
0
+ # Finds the last document matching the given criteria.
0
+ #
0
+ def last(args = {})
0
+ result = find(args)
0
+ result.respond_to?(:last) ? result.last : result
0
+ end
0
+
0
+ #
0
     # Similar to +find+, but a creates document with appropriate slot values if
0
     # not found.
0
     #
...
84
85
86
87
 
88
89
90
91
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
93
94
...
84
85
86
 
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
0
@@ -84,11 +84,28 @@ describe "Meta module", :shared => true do
0
     SomeName.first.should == SomeName.find.first
0
   end
0
 
0
- it "correctly handles finding via UUID on call to Meta#first" do
0
+ it "correctly handles finding via UUID on call to #first" do
0
     a = SomeName.create!(:slot1 => 5)
0
     SomeName.first(a.uuid).should == a
0
   end
0
   
0
+ it "should return last found document matching given criteria on call to #last" do
0
+ a = SomeName.create!(:slot1 => 1)
0
+ b = SomeName.create!(:slot1 => 1)
0
+ SomeName.last(:slot1 => 1).should == SomeName.find(:slot1 => 1).last
0
+ end
0
+
0
+ it "should return last document if no args are passed to #last" do
0
+ a = SomeName.create!(:slot1 => 1)
0
+ b = SomeName.create!(:slot1 => 2)
0
+ SomeName.last.should == SomeName.find.last
0
+ end
0
+
0
+ it "correctly handles finding via UUID on call to #last" do
0
+ a = SomeName.create!(:slot1 => 5)
0
+ SomeName.last(a.uuid).should == a
0
+ end
0
+
0
   it "should raise ArgumentError unless args size is 1 or 2" do
0
     a = SomeName.create!(:slot1 => 1, :slot2 => 2)
0
     lambda { SomeName.find("foo","bar","foobar") }.should raise_error(ArgumentError)

Comments

    No one has commented yet.