Skip to content

Commit

Permalink
Merge pull request #33147 from nsgc/add-api-document-about-migration-…
Browse files Browse the repository at this point in the history
…methods

Add docs for ActiveRecord::Migration#say, #say_with_time, #suppress_messages [ci skip]
  • Loading branch information
kamipo committed Jun 18, 2018
2 parents cad0b7d + 3c63f1e commit c47c289
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions activerecord/lib/active_record/migration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -831,10 +831,14 @@ def announce(message)
write "== %s %s" % [text, "=" * length]
end

# Takes a message argument and outputs it as is.
# A second boolean argument can be passed to specify whether to indent or not.
def say(message, subitem = false)
write "#{subitem ? " ->" : "--"} #{message}"
end

# Outputs text along with how long it took to run its block.
# If the block returns an integer it assumes it is the number of rows affected.
def say_with_time(message)
say(message)
result = nil
Expand All @@ -844,6 +848,7 @@ def say_with_time(message)
result
end

# Takes a block as an argument and suppresses any output generated by the block.
def suppress_messages
save, self.verbose = verbose, false
yield
Expand Down

0 comments on commit c47c289

Please sign in to comment.