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
Instance Method Summary collapse
-
#initialize(item, default_locale) ⇒ SyncPage
constructor
A new instance of SyncPage.
-
#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
Methods inherited from BaseResource
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
#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
#last_page? ⇒ Boolean
Returns wether it is the last sync page
43 44 45 |
# File 'lib/contentful/sync_page.rb', line 43 def last_page? !next_page_url end |
#next_page ⇒ Contentful::SyncPage, void
Requests next sync page from API
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
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 |