Skip to content
Browse files

Merge pull request #16297 from calebthompson/extract-iterator-method

Extract iterator method in AR::SchemaDumper
  • Loading branch information...
2 parents 7bd0af4 + 75f3584 commit 64e2e81bf924f865c217d2949ceaead62bbaf4e9 @rafaelfranca rafaelfranca committed Jul 28, 2014
Showing with 14 additions and 10 deletions.
  1. +14 −10 activerecord/lib/active_record/schema_dumper.rb
View
24 activerecord/lib/active_record/schema_dumper.rb
@@ -92,16 +92,9 @@ def extensions(stream)
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 @@ def foreign_keys(table, stream)
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

0 comments on commit 64e2e81

Please sign in to comment.
Something went wrong with that request. Please try again.