Sha256: 619bd1f0209f6f1f2262cd016d9b9cb937272ca7a141d715a9f756b0a753fa0c
Contents?: true
Size: 703 Bytes
Versions: 17
Compression:
Stored size: 703 Bytes
Contents
module ActiveMocker class CollectionAssociation include Enumerable attr_accessor :collection def initialize(collection=[]) @collection = *collection ||=[] end def each(&block) collection.each do |item| block.call(item) end end def last collection.last end def <<(*records) collection.concat(records.flatten) end def sum(attribute=nil) values = collection.map{ |obj| obj.send(attribute) } values.inject{ |sum, n| sum + n } end def ==(other_ary) collection == other_ary end def method_missing(meth, *args, &block) collection.send(meth, *args, &block) end end end
Version data entries
17 entries across 17 versions & 1 rubygems