Class: Columns::ModelWriter
- Inherits:
-
Object
- Object
- Columns::ModelWriter
- Defined in:
- lib/columns/model_writer.rb
Overview
Public: Add schema info to the end of a ruby model.
Instance Method Summary collapse
- #add_info(model_data) ⇒ Object
-
#initialize(path: './app/models/') ⇒ ModelWriter
constructor
A new instance of ModelWriter.
Constructor Details
#initialize(path: './app/models/') ⇒ ModelWriter
Returns a new instance of ModelWriter.
6 7 8 |
# File 'lib/columns/model_writer.rb', line 6 def initialize(path: './app/models/') @path = path end |
Instance Method Details
#add_info(model_data) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/columns/model_writer.rb', line 10 def add_info(model_data) @model_data = model_data ensure_file_end_with_empty_line if File.exists?(model_path) File.open(model_path, 'a') do |file| file.puts(ExtendedContent.from(@model_data.content)) end end end |