Sha256: 4afa2c65da835261b3adcae6fc72caaf7f7cf0879598f5a40a86d6f44a2f8010

Contents?: true

Size: 703 Bytes

Versions: 4

Compression:

Stored size: 703 Bytes

Contents

# -*- encoding: utf-8 -*-
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

4 entries across 4 versions & 1 rubygems

Version Path
contentful-management-0.0.3 lib/contentful/management/resource/array_like.rb
contentful-management-0.0.2 lib/contentful/management/resource/array_like.rb
contentful-management-0.0.1 lib/contentful/management/resource/array_like.rb
contentful-management-0.0.1.pre lib/contentful/management/resource/array_like.rb