Skip to content

Commit

Permalink
extract factory method and push common code up to abstract adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Mar 15, 2013
1 parent b7b6c22 commit d5f4b53
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Expand Up @@ -16,7 +16,6 @@ class IndexDefinition < Struct.new(:table, :name, :unique, :columns, :lengths, :
# +columns+ attribute of said TableDefinition object, in order to be used # +columns+ attribute of said TableDefinition object, in order to be used
# for generating a number of table creation or table changing SQL statements. # 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: class ColumnDefinition < Struct.new(:base, :name, :type, :limit, :precision, :scale, :default, :null) #:nodoc:

def string_to_binary(value) def string_to_binary(value)
value value
end end
Expand Down Expand Up @@ -296,8 +295,12 @@ def to_sql
end end


private private
def create_column_definition(base, name, type)
ColumnDefinition.new base, name, type
end

def new_column_definition(base, name, type) def new_column_definition(base, name, type)
definition = ColumnDefinition.new base, name, type definition = create_column_definition base, name, type
@columns << definition @columns << definition
@columns_hash[name] = definition @columns_hash[name] = definition
definition definition
Expand Down
Expand Up @@ -340,11 +340,8 @@ def column(name, type = nil, options = {})


private private


def new_column_definition(base, name, type) def create_column_definition(base, name, type)
definition = ColumnDefinition.new base, name, type ColumnDefinition.new base, name, type
@columns << definition
@columns_hash[name] = definition
definition
end end
end end


Expand Down

0 comments on commit d5f4b53

Please sign in to comment.