Class: Contentful::SyncPage
- Inherits:
-
BaseResource
- Object
- BaseResource
- Contentful::SyncPage
- Includes:
- ArrayLike
- Defined in:
- lib/contentful/sync_page.rb
Overview
Wrapper Class for Sync results
Instance Attribute Summary collapse
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#next_page_url ⇒ Object
readonly
Returns the value of attribute next_page_url.
-
#next_sync_url ⇒ Object
readonly
Returns the value of attribute next_sync_url.
-
#sync ⇒ Object
readonly
Returns the value of attribute sync.
Attributes inherited from BaseResource
#_metadata, #default_locale, #raw, #sys
Instance Method Summary collapse
-
#initialize(item, configuration = { default_locale: Contentful::Client::DEFAULT_CONFIGURATION[:default_locale] }) ⇒ SyncPage
constructor
A new instance of SyncPage.
- #inspect ⇒ Object
-
#last_page? ⇒ Boolean
Returns wether it is the last sync page.
-
#next_page ⇒ Contentful::SyncPage, void
Requests next sync page from API.
-
#next_page? ⇒ Boolean
Returns wether there is a next sync page.
Methods included from ArrayLike
#[], #array?, #each_item, #empty?, #last, #size, #to_ary
Methods inherited from BaseResource
#==, #marshal_dump, #marshal_load, #reload
Constructor Details
#initialize(item, configuration = { default_locale: Contentful::Client::DEFAULT_CONFIGURATION[:default_locale] }) ⇒ SyncPage
Returns a new instance of SyncPage.
11 12 13 14 15 16 17 18 19 20 |
# 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 |
Instance Attribute Details
#items ⇒ Object (readonly)
Returns the value of attribute items.
9 10 11 |
# File 'lib/contentful/sync_page.rb', line 9 def items @items end |
#next_page_url ⇒ Object (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_url ⇒ Object (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 |
#sync ⇒ Object (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
#inspect ⇒ Object
23 24 25 |
# 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? ⇒ Boolean
Returns wether it is the last sync page
46 47 48 |
# File 'lib/contentful/sync_page.rb', line 46 def last_page? !next_page_url end |
#next_page ⇒ Contentful::SyncPage, void
Requests next sync page from API
30 31 32 |
# File 'lib/contentful/sync_page.rb', line 30 def next_page sync.get(next_page_url) if next_page? end |
#next_page? ⇒ Boolean
Returns wether there is a next sync page
37 38 39 40 41 |
# File 'lib/contentful/sync_page.rb', line 37 def next_page? # rubocop:disable Style/DoubleNegation !!next_page_url # rubocop:enable Style/DoubleNegation end |