diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-07-28 10:58:23 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-07-28 10:58:23 -0300 |
commit | 64e2e81bf924f865c217d2949ceaead62bbaf4e9 (patch) | |
tree | 553d6701c82140997173ab657f3842393e53bcd9 /activerecord | |
parent | 7bd0af42d6f8541a8247a89e07396c2da159d85d (diff) | |
parent | 75f3584d9b87097377b312d35bd124686723ce4a (diff) | |
download | rails-64e2e81bf924f865c217d2949ceaead62bbaf4e9.tar.gz rails-64e2e81bf924f865c217d2949ceaead62bbaf4e9.tar.bz2 rails-64e2e81bf924f865c217d2949ceaead62bbaf4e9.zip |
Merge pull request #16297 from calebthompson/extract-iterator-method
Extract iterator method in AR::SchemaDumper
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/schema_dumper.rb | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/activerecord/lib/active_record/schema_dumper.rb b/activerecord/lib/active_record/schema_dumper.rb index a94364bde1..fae6427ea1 100644 --- a/activerecord/lib/active_record/schema_dumper.rb +++ b/activerecord/lib/active_record/schema_dumper.rb @@ -92,16 +92,9 @@ HEADER def tables(stream) sorted_tables = @connection.tables.sort - sorted_tables.each do |tbl| - next if ['schema_migrations', ignore_tables].flatten.any? do |ignored| - case ignored - when String; remove_prefix_and_suffix(tbl) == ignored - when Regexp; remove_prefix_and_suffix(tbl) =~ ignored - else - raise StandardError, 'ActiveRecord::SchemaDumper.ignore_tables accepts an array of String and / or Regexp values.' - end - end - table(tbl, stream) + + sorted_tables.each do |table_name| + table(table_name, stream) unless ignored?(table_name) end # dump foreign keys at the end to make sure all dependent tables exist. @@ -254,5 +247,16 @@ HEADER def remove_prefix_and_suffix(table) table.gsub(/^(#{@options[:table_name_prefix]})(.+)(#{@options[:table_name_suffix]})$/, "\\2") end + + def ignored?(table_name) + ['schema_migrations', ignore_tables].flatten.any? do |ignored| + case ignored + when String; remove_prefix_and_suffix(table_name) == ignored + when Regexp; remove_prefix_and_suffix(table_name) =~ ignored + else + raise StandardError, 'ActiveRecord::SchemaDumper.ignore_tables accepts an array of String and / or Regexp values.' + end + end + end end end |