Class: SDBTools::Operation
- Inherits:
-
Object
- Object
- SDBTools::Operation
- Includes:
- Enumerable
- Defined in:
- lib/sdbtools/operation.rb
Overview
An Operation represents a SimpleDB operation and handles the details of re-requesting “next tokens” until the operation is complete.
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#starting_token ⇒ Object
readonly
Returns the value of attribute starting_token.
Instance Method Summary collapse
-
#each ⇒ Object
Yields once for each result set, until there is no next token.
-
#initialize(sdb, method, *args) ⇒ Operation
constructor
A new instance of Operation.
Constructor Details
#initialize(sdb, method, *args) ⇒ Operation
Returns a new instance of Operation.
11 12 13 14 15 16 17 |
# File 'lib/sdbtools/operation.rb', line 11 def initialize(sdb, method, *args) @options = args.last.is_a?(Hash) ? args.pop : {} @sdb = sdb @method = method @args = args @starting_token = @options[:starting_token] end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
8 9 10 |
# File 'lib/sdbtools/operation.rb', line 8 def args @args end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
7 8 9 |
# File 'lib/sdbtools/operation.rb', line 7 def method @method end |
#starting_token ⇒ Object (readonly)
Returns the value of attribute starting_token.
9 10 11 |
# File 'lib/sdbtools/operation.rb', line 9 def starting_token @starting_token end |
Instance Method Details
#each ⇒ Object
Yields once for each result set, until there is no next token.
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/sdbtools/operation.rb', line 20 def each Transaction.open(":#{method} operation") do |t| next_token = starting_token begin args = @args.dup args << next_token results = @sdb.send(@method, *args) yield(results, self) next_token = results[:next_token] end while next_token end end |