Sha256: 6cc41b17f47f6184ce98525461bcbfc3ef4860a9fe72d907628ccb9619a1a470

Contents?: true

Size: 831 Bytes

Versions: 17

Compression:

Stored size: 831 Bytes

Contents

# frozen_string_literal: true
require "forwardable"

module ActiveMocker
  class Collection
    include Enumerable
    extend ::Forwardable
    def_delegators :@collection, :[], :take, :push, :clear, :first, :last, :concat, :replace, :uniq, :count, :size, :length, :empty?, :any?, :many?, :include?, :delete
    alias distinct uniq

    def initialize(collection = [])
      @collection = collection
    end

    def <<(*records)
      collection.concat(records.flatten)
    end

    def each
      collection.each do |item|
        yield(item)
      end
    end

    def to_a
      @collection
    end

    def to_ary
      to_a
    end

    def hash
      @collection.hash
    end

    def ==(val)
      @collection == val
    end

    def blank?
      to_a.blank?
    end

    protected

    attr_accessor :collection
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
active_mocker-2.6.2 lib/active_mocker/mock/collection.rb
active_mocker-2.6.1.beta2 lib/active_mocker/mock/collection.rb
active_mocker-2.6.1.beta lib/active_mocker/mock/collection.rb
active_mocker-2.6.0 lib/active_mocker/mock/collection.rb
active_mocker-2.5.4 lib/active_mocker/mock/collection.rb
active_mocker-2.5.3 lib/active_mocker/mock/collection.rb
active_mocker-2.5.2 lib/active_mocker/mock/collection.rb
active_mocker-2.5.1 lib/active_mocker/mock/collection.rb
active_mocker-2.5.1.pre lib/active_mocker/mock/collection.rb
active_mocker-2.5.0 lib/active_mocker/mock/collection.rb
active_mocker-2.4.4 lib/active_mocker/mock/collection.rb
active_mocker-2.4.3 lib/active_mocker/mock/collection.rb
active_mocker-2.4.2 lib/active_mocker/mock/collection.rb
active_mocker-2.4.1 lib/active_mocker/mock/collection.rb
active_mocker-2.4.0 lib/active_mocker/mock/collection.rb
active_mocker-2.4.0.pre5 lib/active_mocker/mock/collection.rb
active_mocker-2.3.4 lib/active_mocker/mock/collection.rb