Class: Sprig::Reap::SeedFile
- Inherits:
-
Object
- Object
- Sprig::Reap::SeedFile
- Defined in:
- lib/sprig/reap/seed_file.rb
Constant Summary collapse
- DEFAULT_NAMESPACE =
'records'
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.
5 6 7 |
# File 'lib/sprig/reap/seed_file.rb', line 5 def model @model end |
Instance Method Details
#exists? ⇒ Boolean
17 18 19 |
# File 'lib/sprig/reap/seed_file.rb', line 17 def exists? File.exists?(path) end |
#path ⇒ Object
13 14 15 |
# File 'lib/sprig/reap/seed_file.rb', line 13 def path Rails.root.join('db', 'seeds', Sprig::Reap.target_env, "#{model.to_s.tableize.gsub('/', '_')}.yml") end |
#write ⇒ Object
21 22 23 24 25 |
# File 'lib/sprig/reap/seed_file.rb', line 21 def write initialize_file do |file, namespace| file.write model.to_yaml(:namespace => namespace) end end |