Skip to content
Browse files

extract factory method and push common code up to abstract adapter

  • Loading branch information...
1 parent b7b6c22 commit d5f4b5382afc04eb760be02c87db61d907f0ea1b @tenderlove tenderlove committed Mar 14, 2013
View
7 activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
@@ -16,7 +16,6 @@ class IndexDefinition < Struct.new(:table, :name, :unique, :columns, :lengths, :
# +columns+ attribute of said TableDefinition object, in order to be used
# for generating a number of table creation or table changing SQL statements.
class ColumnDefinition < Struct.new(:base, :name, :type, :limit, :precision, :scale, :default, :null) #:nodoc:
-
def string_to_binary(value)
value
end
@@ -296,8 +295,12 @@ def to_sql
end
private
+ def create_column_definition(base, name, type)
+ ColumnDefinition.new base, name, type
+ end
+
def new_column_definition(base, name, type)
- definition = ColumnDefinition.new base, name, type
+ definition = create_column_definition base, name, type
@columns << definition
@columns_hash[name] = definition
definition
View
7 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -340,11 +340,8 @@ def column(name, type = nil, options = {})
private
- def new_column_definition(base, name, type)
- definition = ColumnDefinition.new base, name, type
- @columns << definition
- @columns_hash[name] = definition
- definition
+ def create_column_definition(base, name, type)
+ ColumnDefinition.new base, name, type
end
end

0 comments on commit d5f4b53

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