class Mockumentary::Collection
Attributes
type[RW]
Public Class Methods
new(klass)
click to toggle source
# File lib/mockumentary/collection.rb, line 5 def initialize(klass) self.type = klass end
Public Instance Methods
build(opts={})
click to toggle source
# File lib/mockumentary/collection.rb, line 19 def build(opts={}) self << type.new(opts) self end
create(opts={})
click to toggle source
# File lib/mockumentary/collection.rb, line 24 def create(opts={}) self << type.new(opts).save self end
Also aliased as: create!
delete(*args)
click to toggle source
Calls superclass method
# File lib/mockumentary/collection.rb, line 31 def delete(*args) args.each {|e| super(e)} self end
exist?(element)
click to toggle source
# File lib/mockumentary/collection.rb, line 40 def exist?(element) map(&:id).include?(element.id) end
mock(i=1)
click to toggle source
# File lib/mockumentary/collection.rb, line 9 def mock(i=1) (1..i).each { self << type.mock } self end
mock!(i=1)
click to toggle source
# File lib/mockumentary/collection.rb, line 14 def mock!(i=1) (1..i).each { self << type.mock! } self end