Class: Thredded::DatabaseSeeder::BaseSeedData

Inherits:
Object
  • Object
show all
Includes:
LogTime
Defined in:
lib/thredded/database_seeder.rb

Direct Known Subclasses

CollectionSeedData, FirstSeedData

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from LogTime

included, #log_time, #print_time_diff

Constructor Details

#initialize(seed_database = DatabaseSeeder.new) ⇒ BaseSeedData


247
248
249
# File 'lib/thredded/database_seeder.rb', line 247

def initialize(seed_database = DatabaseSeeder.new)
  @seeder = seed_database
end

Instance Attribute Details

#seederThredded::DatabaseSeeder (readonly)


245
246
247
# File 'lib/thredded/database_seeder.rb', line 245

def seeder
  @seeder
end

Class Method Details

.create(*args) ⇒ Object

Utility method


252
253
254
# File 'lib/thredded/database_seeder.rb', line 252

def self.create(*args)
  new.create(*args)
end

Instance Method Details

#find_or_create(*args) ⇒ Object


258
259
260
261
# File 'lib/thredded/database_seeder.rb', line 258

def find_or_create(*args)
  return @stored if @stored
  @stored = (find || create(*args))
end

#range_of_dates_in_order(up_to: Time.zone.now, count: 1) ⇒ Object


263
264
265
266
# File 'lib/thredded/database_seeder.rb', line 263

def range_of_dates_in_order(up_to: Time.zone.now, count: 1)
  written = up_to
  Array.new(count - 1) { written -= random_duration(10.minutes..6.hours) }.reverse + [up_to]
end