Sha256: 9fbfae9e9aa4c8b6b6e48fc72a07cac45575a5d95e1b3268916aa8608f31fed6

Contents?: true

Size: 678 Bytes

Versions: 39

Compression:

Stored size: 678 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 each each_item

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

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

        alias length size
      end
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
contentful-management-3.8.0 lib/contentful/management/resource/array_like.rb
contentful-management-3.7.0 lib/contentful/management/resource/array_like.rb
contentful-management-3.6.0 lib/contentful/management/resource/array_like.rb
contentful-management-3.5.0 lib/contentful/management/resource/array_like.rb
contentful-management-3.4.0 lib/contentful/management/resource/array_like.rb
contentful-management-3.3.0 lib/contentful/management/resource/array_like.rb
contentful-management-3.2.0 lib/contentful/management/resource/array_like.rb
contentful-management-3.1.0 lib/contentful/management/resource/array_like.rb
contentful-management-3.0.0 lib/contentful/management/resource/array_like.rb
contentful-management-2.13.1 lib/contentful/management/resource/array_like.rb
contentful-management-2.13.0 lib/contentful/management/resource/array_like.rb
contentful-management-2.12.1 lib/contentful/management/resource/array_like.rb
contentful-management-2.12.0 lib/contentful/management/resource/array_like.rb
contentful-management-2.11.0 lib/contentful/management/resource/array_like.rb
contentful-management-2.10.0 lib/contentful/management/resource/array_like.rb
contentful-management-2.9.1 lib/contentful/management/resource/array_like.rb
contentful-management-2.9.0 lib/contentful/management/resource/array_like.rb
contentful-management-2.8.2 lib/contentful/management/resource/array_like.rb
contentful-management-2.8.1 lib/contentful/management/resource/array_like.rb
contentful-management-2.8.0 lib/contentful/management/resource/array_like.rb