Sha256: 3824fe87a44f3e13f2860a692f2f6c9fef85bccfb52488c66c2f4c79b4bdab6c

Contents?: true

Size: 875 Bytes

Versions: 1

Compression:

Stored size: 875 Bytes

Contents

module MicroMicro
  module Collections
    class BaseCollection
      include Enumerable

      delegate :[], :each, :last, :length, :split, to: :members

      # @param members [Array<MicroMicro::Item, MicroMicro::Property, MicroMicro::Relation>]
      def initialize(members = [])
        @members = members

        decorate_members if respond_to?(:decorate_members, true)
      end

      # @return [String]
      def inspect
        format(%(#<#{self.class.name}:%#0x count: #{count}, members: #{members.inspect}>), object_id)
      end

      # @param member [MicroMicro::Item, MicroMicro::Property, MicroMicro::Relation]
      # @return [self]
      def push(member)
        members.push(member)

        decorate_members if respond_to?(:decorate_members, true)

        self
      end

      alias << push

      private

      attr_reader :members
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
micromicro-0.1.0 lib/micro_micro/collections/base_collection.rb