Sha256: ad2fb0fc939e2717e29f75daf1f8080cb5d43ec795b486dd5120494479d9ed42

Contents?: true

Size: 579 Bytes

Versions: 1

Compression:

Stored size: 579 Bytes

Contents

require "seed_report/version"

module SeedReport
  class << self
    def for_model(model, &block)
      initial_count = model.count
      print "#{heading(model)} #{initial_count_display(initial_count)}"

      block.call

      increase = model.count - initial_count
      puts final_count_display(increase)
    end

    def heading(model)
      sprintf("  %-19s", model.name)
    end

    def initial_count_display(count)
      "initial count: #{sprintf("%3d", 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.3.0 lib/seed_report.rb