aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorwangjohn <wangjohn@mit.edu>2013-08-22 17:18:46 -0400
committerwangjohn <wangjohn@mit.edu>2013-08-22 18:06:07 -0400
commit9f82fb3f63015bbbd643bc624a49d98e97803681 (patch)
tree3b527a8278ce2f75d6a11fd4660582512ca7ebe2 /activerecord
parent744ed5c39381cb3e58eba6fab21f42b3408dce53 (diff)
downloadrails-9f82fb3f63015bbbd643bc624a49d98e97803681.tar.gz
rails-9f82fb3f63015bbbd643bc624a49d98e97803681.tar.bz2
rails-9f82fb3f63015bbbd643bc624a49d98e97803681.zip
Creating options for schema dumper.
These options make it easier to change the config from ActiveRecord::Base to use something else inside of the SchemaDumper.
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/schema_dumper.rb21
1 files changed, 16 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/schema_dumper.rb b/activerecord/lib/active_record/schema_dumper.rb
index 1181cc739e..8986d255cd 100644
--- a/activerecord/lib/active_record/schema_dumper.rb
+++ b/activerecord/lib/active_record/schema_dumper.rb
@@ -17,9 +17,19 @@ module ActiveRecord
cattr_accessor :ignore_tables
@@ignore_tables = []
- def self.dump(connection=ActiveRecord::Base.connection, stream=STDOUT)
- new(connection).dump(stream)
- stream
+ class << self
+ def dump(connection=ActiveRecord::Base.connection, stream=STDOUT, config = ActiveRecord::Base)
+ new(connection, generate_options(config)).dump(stream)
+ stream
+ end
+
+ private
+ def generate_options(config)
+ {
+ table_name_prefix: config.table_name_prefix,
+ table_name_suffix: config.table_name_suffix
+ }
+ end
end
def dump(stream)
@@ -32,10 +42,11 @@ module ActiveRecord
private
- def initialize(connection)
+ def initialize(connection, options = {})
@connection = connection
@types = @connection.native_database_types
@version = Migrator::current_version rescue nil
+ @options = options
end
def header(stream)
@@ -201,7 +212,7 @@ HEADER
end
def remove_prefix_and_suffix(table)
- table.gsub(/^(#{ActiveRecord::Base.table_name_prefix})(.+)(#{ActiveRecord::Base.table_name_suffix})$/, "\\2")
+ table.gsub(/^(#{@options[:table_name_prefix]})(.+)(#{@options[:table_name_suffix]})$/, "\\2")
end
end
end