Class: Populate::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/populate/base.rb

Instance Method Summary collapse

Constructor Details

#initialize(klass, amount = 100) ⇒ Base

Returns a new instance of Base.



3
4
5
6
# File 'lib/populate/base.rb', line 3

def initialize(klass, amount = 100)
  @klass = klass
  @amount = amount
end

Instance Method Details

#populate!Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/populate/base.rb', line 8

def populate!
  truncate!
  header "Populating #{quantity} #{@klass.to_s.pluralize}"

  quantity.times do
    models << model = @klass.create{|m| populate_attributes(m)}
    status(model)
  end

  puts
  models
end