Class: Ghost::Seeder::Runner
- Inherits:
-
Object
- Object
- Ghost::Seeder::Runner
- Defined in:
- lib/ghost/seeder/runner.rb
Instance Attribute Summary collapse
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(environment) ⇒ Runner
constructor
A new instance of Runner.
- #run ⇒ Object
Constructor Details
#initialize(environment) ⇒ Runner
Returns a new instance of Runner.
28 29 30 |
# File 'lib/ghost/seeder/runner.rb', line 28 def initialize(environment) @environment = environment end |
Instance Attribute Details
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
26 27 28 |
# File 'lib/ghost/seeder/runner.rb', line 26 def environment @environment end |
Class Method Details
.environment ⇒ Object
17 18 19 |
# File 'lib/ghost/seeder/runner.rb', line 17 def environment ENV["NODE_ENV"] || "development" end |
.run ⇒ Object
13 14 15 |
# File 'lib/ghost/seeder/runner.rb', line 13 def run new(environment).run end |
.wipe_db? ⇒ Boolean
21 22 23 |
# File 'lib/ghost/seeder/runner.rb', line 21 def wipe_db? ENV["WIPE_DB"] end |
Instance Method Details
#run ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ghost/seeder/runner.rb', line 32 def run db.connect! Logger.warn "seeding database for", environment klasses.each do |klass| klass.wipe_records! if self.class.wipe_db? klass.perform_queries Logger.success klass end db.disconnect! Logger.success "finished seeding!" end |