Sha256: a3197f8b8ad3c6a8910274dad03ac6e943fdc49248e1600a676c4a0fc1a38388

Contents?: true

Size: 1.37 KB

Versions: 8

Compression:

Stored size: 1.37 KB

Contents

# frozen_string_literal: true

module Vedeu

  module Repositories

    # Provides collection related query/command methods.
    #
    # @api private
    #
    module Assemblage

      include Enumerable

      # Return an individual element or collection of elements (if
      # the given index is a Range).
      #
      # @param index [Fixnum|Range]
      # @return [void]
      def [](index)
        collection[index]
      end

      # Returns a boolean indicating whether the collection is not
      # empty.
      #
      # @param block [Proc]
      # @return [Boolean]
      def any?(&block)
        collection.any?(&block)
      end

      # Provides iteration over the collection.
      #
      # @param block [Proc]
      # @return [Enumerator]
      def each(&block)
        collection.each(&block)
      end

      # Returns a boolean indicating whether the collection is empty.
      #
      # @return [Boolean]
      def empty?
        collection.empty?
      end

      # An object is equal when its values are the same.
      #
      # @param other [void]
      # @return [Boolean]
      def eql?(other)
        self.class.equal?(other.class) && collection == other.collection
      end
      alias == eql?

      # Return the size of the collection.
      #
      # @return [Fixnum]
      def size
        collection.size
      end

    end # Collection

  end # Repositories

end # Vedeu

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
vedeu-0.8.20 lib/vedeu/repositories/assemblage.rb
vedeu-0.8.19 lib/vedeu/repositories/assemblage.rb
vedeu-0.8.18 lib/vedeu/repositories/assemblage.rb
vedeu-0.8.17 lib/vedeu/repositories/assemblage.rb
vedeu-0.8.16 lib/vedeu/repositories/assemblage.rb
vedeu-0.8.15 lib/vedeu/repositories/assemblage.rb
vedeu-0.8.14 lib/vedeu/repositories/assemblage.rb
vedeu-0.8.13 lib/vedeu/repositories/assemblage.rb