Class: Contentful::SyncPage

Inherits:
BaseResource show all
Includes:
ArrayLike
Defined in:
lib/contentful/sync_page.rb

Overview

Wrapper Class for Sync results

Instance Attribute Summary collapse

Attributes inherited from BaseResource

#default_locale, #raw, #sys

Instance Method Summary collapse

Methods included from ArrayLike

#[], #array?, #each_item, #empty?, #last, #size

Methods inherited from BaseResource

#==, #reload

Constructor Details

#initialize(item, default_locale) ⇒ SyncPage

Returns a new instance of SyncPage



11
12
13
14
15
16
17
# File 'lib/contentful/sync_page.rb', line 11

def initialize(item, default_locale, *)
  super(item, { default_locale: default_locale }, true)

  @items = item.fetch('items', [])
  @next_sync_url = item.fetch('nextSyncUrl', nil)
  @next_page_url = item.fetch('nextPageUrl', nil)
end

Instance Attribute Details

#itemsObject (readonly)

Returns the value of attribute items



9
10
11
# File 'lib/contentful/sync_page.rb', line 9

def items
  @items
end

#next_page_urlObject (readonly)

Returns the value of attribute next_page_url



9
10
11
# File 'lib/contentful/sync_page.rb', line 9

def next_page_url
  @next_page_url
end

#next_sync_urlObject (readonly)

Returns the value of attribute next_sync_url



9
10
11
# File 'lib/contentful/sync_page.rb', line 9

def next_sync_url
  @next_sync_url
end

#syncObject (readonly)

Returns the value of attribute sync



9
10
11
# File 'lib/contentful/sync_page.rb', line 9

def sync
  @sync
end

Instance Method Details

#last_page?Boolean

Returns wether it is the last sync page

Returns:

  • (Boolean)


43
44
45
# File 'lib/contentful/sync_page.rb', line 43

def last_page?
  !next_page_url
end

#next_pageContentful::SyncPage, void

Requests next sync page from API

Returns:



27
28
29
# File 'lib/contentful/sync_page.rb', line 27

def next_page
  sync.get(next_page_url) if next_page?
end

#next_page?Boolean

Returns wether there is a next sync page

Returns:

  • (Boolean)


34
35
36
37
38
# File 'lib/contentful/sync_page.rb', line 34

def next_page?
  # rubocop:disable Style/DoubleNegation
  !!next_page_url
  # rubocop:enable Style/DoubleNegation
end