Sha256: 981570c788ed910e546531b4d050f8262b4cc40368d89a9bafa412a2bda5dd39

Contents?: true

Size: 490 Bytes

Versions: 6

Compression:

Stored size: 490 Bytes

Contents

module T
  module Collectable

    def collect_with_cursor(collection=[], cursor=-1, &block)
      object = yield cursor
      collection += object.collection
      object.last? ? collection : collect_with_cursor(collection, object.next_cursor, &block)
    end

    def collect_with_max_id(collection=[], max_id=nil, &block)
      array = yield max_id
      collection += array
      array.empty? ? collection : collect_with_max_id(collection, array.last.id - 1, &block)
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
t-0.9.4 lib/t/collectable.rb
t-0.9.3 lib/t/collectable.rb
t-0.9.2 lib/t/collectable.rb
t-0.9.1 lib/t/collectable.rb
t-0.9.0 lib/t/collectable.rb
t-0.8.3 lib/t/collectable.rb