Sha256: 1b101a00ad491e260b3a190a72f1722e35c0ec746c7dd3cd0dd562def58d44d2

Contents?: true

Size: 722 Bytes

Versions: 1

Compression:

Stored size: 722 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_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

1 entries across 1 versions & 1 rubygems

Version Path
contentful-management-0.2.1 lib/contentful/management/resource/array_like.rb