Class: Contentful::Array
- Inherits:
-
Object
- Object
- Contentful::Array
- Includes:
- Resource, Resource::SystemProperties, Enumerable
- Defined in:
- lib/contentful/array.rb
Overview
Resource Class for Arrays (e.g. search results) www.contentful.com/developers/documentation/content-delivery-api/#arrays It also provides an #each method and includes Ruby’s Enumerable module (gives you methods like #min, #first, etc)
Constant Summary collapse
- DEFAULT_LIMIT =
100
Constants included from Resource::SystemProperties
Resource::SystemProperties::SYS_COERCIONS
Constants included from Resource
Instance Attribute Summary
Attributes included from Resource::SystemProperties
Attributes included from Resource
#client, #properties, #request
Instance Method Summary collapse
-
#array? ⇒ Boolean
Only returns true for Contentful::Array.
-
#each(&block) ⇒ Object
Delegates to items#each.
-
#empty? ⇒ Boolean
Delegates to items#empty?.
-
#next_page ⇒ Object
Simplifies pagination.
Methods included from Resource::SystemProperties
included, #initialize, #inspect
Methods included from Resource
#fields, #initialize, #inspect, #reload, #sys
Instance Method Details
#array? ⇒ Boolean
Only returns true for Contentful::Array
20 21 22 |
# File 'lib/contentful/array.rb', line 20 def array? true end |
#each(&block) ⇒ Object
Delegates to items#each
37 38 39 |
# File 'lib/contentful/array.rb', line 37 def each(&block) items.each(&block) end |
#empty? ⇒ Boolean
Delegates to items#empty?
42 43 44 |
# File 'lib/contentful/array.rb', line 42 def empty? items.empty? end |
#next_page ⇒ Object
Simplifies pagination
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/contentful/array.rb', line 25 def next_page if request new_skip = (skip || 0) + (limit || DEFAULT_LIMIT) new_request = request.copy new_request.query[:skip] = new_skip new_request.get else false end end |