class Contentful::SyncPage

Wrapper Class for Sync results

Attributes

items[R]
next_page_url[R]
next_sync_url[R]
sync[R]

Public Class Methods

new(item, configuration = { default_locale: Contentful::Client::DEFAULT_CONFIGURATION[:default_locale] }, *) click to toggle source
Calls superclass method Contentful::BaseResource::new
# File lib/contentful/sync_page.rb, line 11
def initialize(item,
               configuration = {
                 default_locale: Contentful::Client::DEFAULT_CONFIGURATION[:default_locale]
               }, *)
  super(item, configuration, true)

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

Public Instance Methods

inspect() click to toggle source

@private

# File lib/contentful/sync_page.rb, line 23
def inspect
  "<#{repr_name} next_sync_url='#{next_sync_url}' last_page=#{last_page?}>"
end
last_page?() click to toggle source

Returns wether it is the last sync page

@return [Boolean]

# File lib/contentful/sync_page.rb, line 46
def last_page?
  !next_page_url
end
next_page() click to toggle source

Requests next sync page from API

@return [Contentful::SyncPage, void]

# File lib/contentful/sync_page.rb, line 30
def next_page
  sync.get(next_page_url) if next_page?
end
next_page?() click to toggle source

Returns wether there is a next sync page

@return [Boolean]

# File lib/contentful/sync_page.rb, line 37
def next_page?
  # rubocop:disable Style/DoubleNegation
  !!next_page_url
  # rubocop:enable Style/DoubleNegation
end