Sha256: 74371d1e0e822e2d7f31e080c9ea4ce5338f07094bf94243877e78ffc15dc3c4

Contents?: true

Size: 662 Bytes

Versions: 1

Compression:

Stored size: 662 Bytes

Contents

require "seed_report/version"

module SeedReport
  class << self
    def report_growth(of_model:, &block)
      print "#{heading(of_model)} #{initial_count_display(of_model)}"
      initial_count = of_model.count
      block.call
      increase = of_model.count - initial_count
      puts final_count_display(increase)
    end

    def heading(model)
      class_name = "#{model.table_name.gsub('_',' ').titleize}..."
      sprintf("  %-19s", class_name)
    end

    def initial_count_display(model)
      "initial count: #{sprintf("%3d", model.count)}"
    end

    def final_count_display(amount)
      ", #{sprintf("%3s", amount)} created"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
seed_report-0.1.0 lib/seed_report.rb