appoxy-simple_record 1.1.10 → 1.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/results_array.rb +3 -7
- data/test/test_simple_record.rb +6 -1
- metadata +1 -1
data/lib/results_array.rb
CHANGED
@@ -21,13 +21,9 @@ module SimpleRecord
|
|
21
21
|
@items << val
|
22
22
|
end
|
23
23
|
|
24
|
-
def [](i)
|
24
|
+
def [](*i)
|
25
25
|
# todo: load items up to i if size > i
|
26
|
-
@items[i]
|
27
|
-
end
|
28
|
-
|
29
|
-
def [](i,j)
|
30
|
-
@items[i,j]
|
26
|
+
@items[*i]
|
31
27
|
end
|
32
28
|
|
33
29
|
def first
|
@@ -87,7 +83,7 @@ module SimpleRecord
|
|
87
83
|
#puts 'params in block=' + params.inspect
|
88
84
|
options[:next_token] = next_token
|
89
85
|
res = clz.find(*params)
|
90
|
-
items = res.items
|
86
|
+
items = res.items # get the real items array from the ResultsArray
|
91
87
|
items.each do |item|
|
92
88
|
@items << item
|
93
89
|
end
|
data/test/test_simple_record.rb
CHANGED
@@ -172,7 +172,7 @@ class TestSimpleRecord < Test::Unit::TestCase
|
|
172
172
|
def test_count
|
173
173
|
|
174
174
|
SimpleRecord.stats.clear
|
175
|
-
|
175
|
+
|
176
176
|
count = MyModel.find(:count) # select 1
|
177
177
|
assert count > 0
|
178
178
|
|
@@ -222,5 +222,10 @@ class TestSimpleRecord < Test::Unit::TestCase
|
|
222
222
|
assert !mms.last.nil?
|
223
223
|
assert !mms.empty?
|
224
224
|
assert mms.include?(mms[0])
|
225
|
+
|
226
|
+
assert mms[2,2].size == 2
|
227
|
+
assert mms[2..5].size == 4
|
228
|
+
assert mms[2...5].size == 3
|
229
|
+
|
225
230
|
end
|
226
231
|
end
|