Sha256: e29d44da8d16994f23ed2ba003abb788f9537460aafc0d68daad363f53e20cb8
Contents?: true
Size: 880 Bytes
Versions: 2
Compression:
Stored size: 880 Bytes
Contents
module ActiveMock class Collection include Enumerable def initialize(collection=[]) @collection = [*collection] end def <<(*records) collection.concat(records.flatten) end extend Forwardable def_delegators :@collection, :take, :push, :clear, :first, :last, :concat, :replace, :distinct, :uniq, :count, :size, :length, :empty?, :any?, :include?, :delete alias distinct uniq def select(&block) collection.select(&block) end def each(&block) collection.each do |item| block.call(item) end end def map(&block) collection.map do |item| block.call(item) end end def to_a @collection end def ==(val) return false if val.nil? collection.hash == val.hash end private def collection @collection end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
active_mocker-1.4.2 | lib/active_mock/collection.rb |
active_mocker-1.4.1 | lib/active_mock/collection.rb |