Skip to content

Commit

Permalink
added support for scan_index_forward when chaining, made it so start …
Browse files Browse the repository at this point in the history
…when chaining works correctly.
  • Loading branch information
bcoe committed Nov 6, 2012
1 parent 2a3dbd2 commit 67b4093
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/dynamoid/criteria.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Criteria

module ClassMethods

[:where, :all, :first, :each, :limit, :start].each do |meth|
[:where, :all, :first, :each, :limit, :start, :scan_index_forward].each do |meth|
# Return a criteria chain in response to a method that will begin or end a chain. For more information,
# see Dynamoid::Criteria::Chain.
#
Expand Down
7 changes: 7 additions & 0 deletions lib/dynamoid/criteria/chain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def initialize(source)
@query = {}
@source = source
@consistent_read = false
@scan_index_forward = true
end

# The workhorse method of the criteria chain. Each key in the passed in hash will become another criteria that the
Expand Down Expand Up @@ -63,6 +64,11 @@ def start(start)
self
end

def scan_index_forward(scan_index_forward)
@scan_index_forward = scan_index_forward
self
end

# Allows you to use the results of a search as an enumerable over the results found.
#
# @since 0.2.0
Expand Down Expand Up @@ -227,6 +233,7 @@ def query_opts
opts = {}
opts[:limit] = @limit if @limit
opts[:next_token] = start_key if @start
opts[:scan_index_forward] = @scan_index_forward
opts
end
end
Expand Down

0 comments on commit 67b4093

Please sign in to comment.