Class: DbSeeder::Formatter::Ruby
- Defined in:
- lib/db_seeder/formatter.rb
Instance Method Summary collapse
- #format(records) ⇒ Object
-
#initialize(model_name = nil) ⇒ Ruby
constructor
A new instance of Ruby.
Constructor Details
#initialize(model_name = nil) ⇒ Ruby
Returns a new instance of Ruby.
12 13 14 |
# File 'lib/db_seeder/formatter.rb', line 12 def initialize(model_name = nil) @model_name = model_name end |
Instance Method Details
#format(records) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/db_seeder/formatter.rb', line 16 def format(records) return "" if records.empty? lines = ["# frozen_string_literal: true", ""] lines << "# Seeds for #{@model_name}" if @model_name lines << "" records.each do |record| lines << format_record(record) end lines.join("\n") end |