Class: DirtySeed::Seeder

Inherits:
Object
  • Object
show all
Defined in:
lib/dirty_seed/seeder.rb

Overview

Represents an Active Record model

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model) ⇒ DirtySeed::Seeder

Initializes an record

Parameters:



11
12
13
14
15
# File 'lib/dirty_seed/seeder.rb', line 11

def initialize(model)
  @model = model
  @records = []
  @errors = []
end

Instance Attribute Details

#errorsObject

Returns the value of attribute errors.



6
7
8
# File 'lib/dirty_seed/seeder.rb', line 6

def errors
  @errors
end

#modelObject (readonly)

Returns the value of attribute model.



6
7
8
# File 'lib/dirty_seed/seeder.rb', line 6

def model
  @model
end

#recordsObject (readonly)

Returns the value of attribute records.



6
7
8
# File 'lib/dirty_seed/seeder.rb', line 6

def records
  @records
end

Instance Method Details

#seed(qty = 1) ⇒ Array<Object>

Creates records

Parameters:

  • count (Integer)

Returns:

  • (Array<Object>)


20
21
22
23
24
25
# File 'lib/dirty_seed/seeder.rb', line 20

def seed(qty = 1)
  self.quantity = qty
  logger.seed_model_message(model)
  create_records
  records
end