Class: Iron::Seed

Inherits:
Object
  • Object
show all
Defined in:
app/models/iron/seed.rb

Constant Summary collapse

DEFAULT_PATH =
"db/seeds/iron.zip"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.dump(path = nil) ⇒ Object



5
# File 'app/models/iron/seed.rb', line 5

def self.dump(path = nil) = new(path).dump

.load(path = nil) ⇒ Object



6
# File 'app/models/iron/seed.rb', line 6

def self.load(path = nil) = new(path).load

Instance Method Details

#dumpObject



8
9
10
11
# File 'app/models/iron/seed.rb', line 8

def dump
  FileUtils.mkdir_p(path.dirname)
  Exporter.new(path).export
end

#loadObject



13
14
15
16
17
18
19
20
21
# File 'app/models/iron/seed.rb', line 13

def load
  return unless path.exist?
  return if already_seeded?

  user,  = bootstrap
  Current.set(user: user, account: ) do
    Importer.new(path).import
  end
end