Navigation Menu

Skip to content

Commit

Permalink
Added more Array methods to ResultsArray.
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown committed Aug 4, 2009
1 parent 4d0d210 commit c845fe1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
8 changes: 1 addition & 7 deletions VERSION.yml
@@ -1,11 +1,5 @@
---
:major: 1
:minor: 1
:patch: 10






:patch: 11

10 changes: 3 additions & 7 deletions lib/results_array.rb
Expand Up @@ -21,13 +21,9 @@ def << (val)
@items << val
end

def [](i)
def [](*i)
# todo: load items up to i if size > i
@items[i]
end

def [](i,j)
@items[i,j]
@items[*i]
end

def first
Expand Down Expand Up @@ -87,7 +83,7 @@ def each(&blk)
#puts 'params in block=' + params.inspect
options[:next_token] = next_token
res = clz.find(*params)
items = res.items
items = res.items # get the real items array from the ResultsArray
items.each do |item|
@items << item
end
Expand Down
2 changes: 1 addition & 1 deletion simple_record.gemspec
Expand Up @@ -2,7 +2,7 @@

Gem::Specification.new do |s|
s.name = %q{simple_record}
s.version = "1.1.10"
s.version = "1.1.11"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Travis Reeder", "RightScale"]
Expand Down
7 changes: 6 additions & 1 deletion test/test_simple_record.rb
Expand Up @@ -172,7 +172,7 @@ def test_changed
def test_count

SimpleRecord.stats.clear

count = MyModel.find(:count) # select 1
assert count > 0

Expand Down Expand Up @@ -222,5 +222,10 @@ def test_results_array
assert !mms.last.nil?
assert !mms.empty?
assert mms.include?(mms[0])

assert mms[2,2].size == 2
assert mms[2..5].size == 4
assert mms[2...5].size == 3

end
end

0 comments on commit c845fe1

Please sign in to comment.