aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2018-06-18 19:24:23 +0900
committerGitHub <noreply@github.com>2018-06-18 19:24:23 +0900
commitc47c289ac02cb60e8b01bb8b1892c040794b418f (patch)
tree80a81dd1361a72fc091cae2ab9048b4d62b8da1b
parentcad0b7d91dbc5abf4b0d7fdbcf2d0620557a3b0f (diff)
parent3c63f1e02159dfc728602ac9881d4b852759d514 (diff)
downloadrails-c47c289ac02cb60e8b01bb8b1892c040794b418f.tar.gz
rails-c47c289ac02cb60e8b01bb8b1892c040794b418f.tar.bz2
rails-c47c289ac02cb60e8b01bb8b1892c040794b418f.zip
Merge pull request #33147 from nsgc/add-api-document-about-migration-methods
Add docs for ActiveRecord::Migration#say, #say_with_time, #suppress_messages [ci skip]
-rw-r--r--activerecord/lib/active_record/migration.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb
index 025201c20b..6ace973c29 100644
--- a/activerecord/lib/active_record/migration.rb
+++ b/activerecord/lib/active_record/migration.rb
@@ -831,10 +831,14 @@ module ActiveRecord
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
@@ -844,6 +848,7 @@ module ActiveRecord
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