Sha256: c1250d6b39400399d3f1be70cdcce072eeb4c0311ff31fd1b314c53d290d9ed0
Contents?: true
Size: 706 Bytes
Versions: 2
Compression:
Stored size: 706 Bytes
Contents
module Mockumentary class Collection < Array attr_accessor :type def initialize(klass) self.type = klass end def mock(i=1) (1..i).each { self << type.mock } self end def mock!(i=1) (1..i).each { self << type.mock! } self end def build(opts={}) self << type.new(opts) self end def create(opts={}) self << type.new(opts).save self end alias :create! :create def delete(*args) args.each {|e| super(e)} self end alias :delete_all :clear alias :destroy_all :clear alias :reset :clear def exist?(element) map(&:id).include?(element.id) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mockumentary-0.2.1 | lib/mockumentary/collection.rb |
mockumentary-0.2.0 | lib/mockumentary/collection.rb |