Class: Harvixture::Model
- Inherits:
-
Object
- Object
- Harvixture::Model
- Defined in:
- lib/harvixture/model.rb
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Instance Method Summary collapse
- #filename ⇒ Object
-
#initialize(object) ⇒ Model
constructor
A new instance of Model.
- #write_fixture ⇒ Object
Constructor Details
#initialize(object) ⇒ Model
Returns a new instance of Model.
5 6 7 |
# File 'lib/harvixture/model.rb', line 5 def initialize(object) @object = object end |
Instance Attribute Details
#object ⇒ Object (readonly)
Returns the value of attribute object.
4 5 6 |
# File 'lib/harvixture/model.rb', line 4 def object @object end |
Instance Method Details
#filename ⇒ Object
17 18 19 |
# File 'lib/harvixture/model.rb', line 17 def filename File.join(RAILS_ROOT, Config.output_dir, "#{object.class.table_name}.yml") end |
#write_fixture ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/harvixture/model.rb', line 9 def write_fixture FileUtils.mkdir_p(File.dirname(filename)) File.open(filename, 'w+') { |file| file.print '---' } unless File.exist?(filename) File.open(filename, 'a+') do |file| file.puts object.to_harvixture end end |