Module: Contentful::Resource::ArrayLike

Includes:
Enumerable
Included in:
Array, SyncPage
Defined in:
lib/contentful/resource/array_like.rb

Overview

Useful methods for array-like resources that can be included if an :items property exists

Instance Method Summary collapse

Instance Method Details

#array?true

Returns true for array-like resources

Returns:

  • (true)


11
12
13
# File 'lib/contentful/resource/array_like.rb', line 11

def array?
  true
end

#each_item {|Contentful::Entry, Contentful::Asset| ... } ⇒ Object Also known as: each

Delegates to items#each



18
19
20
# File 'lib/contentful/resource/array_like.rb', line 18

def each_item(&block)
  items.each(&block)
end

#empty?Boolean

Delegates to items#empty?

Returns:

  • (Boolean)


26
27
28
# File 'lib/contentful/resource/array_like.rb', line 26

def empty?
  items.empty?
end

#sizeNumber Also known as: length

Delegetes to items#size

Returns:

  • (Number)


33
34
35
# File 'lib/contentful/resource/array_like.rb', line 33

def size
  items.size
end