Sha256: d866a655ad72f931b36e80968d463aad0b1ef2949d5e0ead7b12e49c35eb115b

Contents?: true

Size: 696 Bytes

Versions: 12

Compression:

Stored size: 696 Bytes

Contents

module Contentful
  module Management
    module Resource
      # Useful methods for array-like resources that can be included if an
      # :items property exists
      module ArrayLike
        include Enumerable

        # Returns true for array-like resources
        def array?
          true
        end

        # Delegates to items#each
        def each_item(&block)
          items.each(&block)
        end

        alias_method :each, :each_item

        # Delegates to items#empty?
        def empty?
          items.empty?
        end

        # Delegetes to items#size
        def size
          items.size
        end

        alias_method :length, :size
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
contentful-management-0.8.0 lib/contentful/management/resource/array_like.rb
contentful-management-0.7.3 lib/contentful/management/resource/array_like.rb
contentful-management-0.7.2 lib/contentful/management/resource/array_like.rb
contentful-management-0.7.1 lib/contentful/management/resource/array_like.rb
contentful-management-0.7.0 lib/contentful/management/resource/array_like.rb
contentful-management-0.6.1 lib/contentful/management/resource/array_like.rb
contentful-management-0.6.0 lib/contentful/management/resource/array_like.rb
contentful-management-0.5.0 lib/contentful/management/resource/array_like.rb
contentful-management-0.4.1 lib/contentful/management/resource/array_like.rb
contentful-management-0.4.0 lib/contentful/management/resource/array_like.rb
contentful-management-0.3.1 lib/contentful/management/resource/array_like.rb
contentful-management-0.3.0 lib/contentful/management/resource/array_like.rb