appoxy-simple_record 1.1.8 → 1.1.9

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 CHANGED
@@ -1,4 +1,7 @@
1
1
  module SimpleRecord
2
+
3
+ #
4
+ # We need to make this behave as if the full set were loaded into the array.
2
5
  class ResultsArray
3
6
 
4
7
  attr_reader :next_token, :clz, :params, :items, :i
@@ -17,11 +20,28 @@ module SimpleRecord
17
20
  end
18
21
 
19
22
  def [](i)
23
+ # todo: load items up to i if size > i
20
24
  @items[i]
21
25
  end
22
26
 
23
27
  def first
24
- @items[0] if @items.size > 0
28
+ @items[0]
29
+ end
30
+
31
+ def last
32
+ @items[@items.length-1]
33
+ end
34
+
35
+ def empty?
36
+ @items.empty?
37
+ end
38
+
39
+ def include?(obj)
40
+ @items.include?(obj)
41
+ end
42
+
43
+ def include?(obj)
44
+ @items.include?(obj)
25
45
  end
26
46
 
27
47
  def size
@@ -39,7 +59,6 @@ module SimpleRecord
39
59
  return size
40
60
  end
41
61
 
42
-
43
62
  def each(&blk)
44
63
  limit = nil
45
64
  if params.size > 1
@@ -215,4 +215,12 @@ class TestSimpleRecord < Test::Unit::TestCase
215
215
  # puts 'x=' + x.id
216
216
  #end
217
217
  end
218
+
219
+ def test_results_array
220
+ mms = MyModel.find(:all) # select 2
221
+ assert !mms.first.nil?
222
+ assert !mms.last.nil?
223
+ assert !mms.empty?
224
+ assert mms.include?(mms[0])
225
+ end
218
226
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appoxy-simple_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.8
4
+ version: 1.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Travis Reeder