Class: LolDba::Writer
- Inherits:
-
Object
- Object
- LolDba::Writer
- Defined in:
- lib/lol_dba/sql_migrations/writer.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(file_name) ⇒ Writer
constructor
A new instance of Writer.
- #write(string) ⇒ Object
Constructor Details
#initialize(file_name) ⇒ Writer
Returns a new instance of Writer.
3 4 5 |
# File 'lib/lol_dba/sql_migrations/writer.rb', line 3 def initialize(file_name) @file_name = file_name end |
Class Method Details
.output_dir ⇒ Object
22 23 24 |
# File 'lib/lol_dba/sql_migrations/writer.rb', line 22 def self.output_dir File.join(Rails.root, 'db', 'migrate_sql') end |
.reset_output_dir ⇒ Object
7 8 9 10 |
# File 'lib/lol_dba/sql_migrations/writer.rb', line 7 def self.reset_output_dir FileUtils.rm_rf output_dir Dir.mkdir output_dir end |
Instance Method Details
#write(string) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/lol_dba/sql_migrations/writer.rb', line 12 def write(string) return unless @file_name.present? File.open(path, 'a') do |file| file << string << ";\n" file.close end end |