Class: Sink::PageCursorSharedRef

Inherits:
Object
  • Object
show all
Defined in:
lib/sink/page_cursor_shared_ref.rb

Defined Under Namespace

Classes: PageCursorSharedRefPagination

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dataArray

Returns:

  • (Array)

24
25
26
# File 'lib/sink/page_cursor_shared_ref.rb', line 24

def data
  @data
end

#paginationSink::Models::PageCursorSharedRefPagination


27
28
29
# File 'lib/sink/page_cursor_shared_ref.rb', line 27

def pagination
  @pagination
end

Instance Method Details

#auto_paging_each(&blk) ⇒ nil

Returns:

  • (nil)
[View source]

55
56
57
58
59
60
61
62
63
64
65
# File 'lib/sink/page_cursor_shared_ref.rb', line 55

def auto_paging_each(&blk)
  if !blk
    raise "A block must be given to #auto_paging_each"
  end
  page = self
  loop do
    page.data.each { |e| blk.call(e) }
    break if !page.next_page?
    page = page.next_page
  end
end

#inspectObject

Returns String.

Returns:

  • String

[View source]

68
69
70
# File 'lib/sink/page_cursor_shared_ref.rb', line 68

def inspect
  "#<#{selfl.class}:0x#{object_id.to_s(16)} data=#{data.inspect} pagination=#{pagination.inspect}>"
end

#next_pageSink::PageCursorSharedRef

[View source]

47
48
49
50
51
52
# File 'lib/sink/page_cursor_shared_ref.rb', line 47

def next_page
  if !next_page?
    raise "No more pages available; please check #next_page? before calling #next_page"
  end
  client.request(Util.deep_merge(req, {query: {cursor: cursor}}), opts)
end

#next_page?Boolean

Returns:

  • (Boolean)
[View source]

42
43
44
# File 'lib/sink/page_cursor_shared_ref.rb', line 42

def next_page?
  !pagination.cursor.nil?
end