Class: Sprig::Reap::SeedFile
- Inherits:
-
Object
- Object
- Sprig::Reap::SeedFile
- Includes:
- Logging
- Defined in:
- lib/sprig/reap/seed_file.rb
Constant Summary collapse
- DEFAULT_NAMESPACE =
'records'
Constants included from Logging
Logging::LOG_COLORS, Logging::LOG_LEVELS
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
- #exists? ⇒ Boolean
-
#initialize(model) ⇒ SeedFile
constructor
A new instance of SeedFile.
- #path ⇒ Object
- #write ⇒ Object
Constructor Details
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
7 8 9 |
# File 'lib/sprig/reap/seed_file.rb', line 7 def model @model end |
Instance Method Details
#exists? ⇒ Boolean
19 20 21 |
# File 'lib/sprig/reap/seed_file.rb', line 19 def exists? File.exists?(path) end |
#path ⇒ Object
15 16 17 |
# File 'lib/sprig/reap/seed_file.rb', line 15 def path Rails.root.join('db', 'seeds', Sprig::Reap.target_env, "#{model.to_s.tableize.gsub('/', '_')}.yml") end |
#write ⇒ Object
23 24 25 26 27 28 |
# File 'lib/sprig/reap/seed_file.rb', line 23 def write initialize_file do |file, namespace| file.write model.to_yaml(:namespace => namespace) log_info "Successfully reaped records for #{model}...\r" end end |