Method: Orchestrate::Collection::KeyValueList#each
- Defined in:
- lib/orchestrate/collection.rb
#each ⇒ Object #each {|key_value| ... } ⇒ Object
Iterates over each KeyValue item in the collection. Used as the basis for Enumerable methods. Items are provided in lexicographically sorted order by key name.
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 |
# File 'lib/orchestrate/collection.rb', line 306 def each params = {} if range[:begin] begin_key = range[:begin_inclusive] ? :start : :after params[begin_key] = range[:begin] end if range[:end] end_key = range[:end_inclusive] ? :end : :before params[end_key] = range[:end] end params[:limit] = range[:limit] @response ||= collection.perform(:list, params) return enum_for(:each) unless block_given? raise ResultsNotReady.new if collection.app.inside_parallel? loop do @response.results.each do |doc| yield KeyValue.from_listing(collection, doc, @response) end break unless @response.next_link @response = @response.next_results end @response = nil end |