Parent

SQL::TableCreator::Column

Attributes

name[RW]
type[RW]

Public Class Methods

new(adapter, name, type, opts = {}) click to toggle source
    # File lib/dm-migrations/sql/table_creator.rb, line 56
56:       def initialize(adapter, name, type, opts = {})
57:         @adapter = adapter
58:         @name = name.to_s
59:         @opts = opts
60:         @type = build_type(type)
61:       end

Public Instance Methods

to_sql() click to toggle source
    # File lib/dm-migrations/sql/table_creator.rb, line 63
63:       def to_sql
64:         type
65:       end

Private Instance Methods

build_type(type_class) click to toggle source
     # File lib/dm-migrations/sql/table_creator.rb, line 69
 69:       def build_type(type_class)
 70:         schema = { :name => @name, :quote_column_name => quoted_name }
 71: 
 72:         [ :nullable, :nullable? ].each do |option|
 73:           next if (value = schema.delete(option)).nil?
 74:           warn "#{option.inspect} is deprecated, use :allow_nil instead"
 75:           schema[:allow_nil] = value unless schema.key?(:allow_nil)
 76:         end
 77: 
 78:         unless schema.key?(:allow_nil)
 79:           schema[:allow_nil] = !schema[:not_null]
 80:         end
 81: 
 82:         if type_class.kind_of?(String)
 83:           schema[:primitive] = type_class
 84:         else
 85:           type_map  = @adapter.class.type_map
 86:           primitive = type_class.respond_to?(:primitive) ? type_class.primitive : type_class
 87:           options   = (type_map[type_class] || type_map[primitive])
 88: 
 89:           schema.update(type_class.options) if type_class.respond_to?(:options)
 90:           schema.update(options)
 91: 
 92:           schema.delete(:length) if type_class == DataMapper::Property::Text
 93:         end
 94: 
 95:         schema.update(@opts)
 96: 
 97:         schema[:length] = schema.delete(:size) if schema.key?(:size)
 98: 
 99:         @adapter.send(:with_connection) do |connection|
100:           @adapter.property_schema_statement(connection, schema)
101:         end
102:       end
quoted_name() click to toggle source
     # File lib/dm-migrations/sql/table_creator.rb, line 104
104:       def quoted_name
105:         @adapter.send(:quote_name, name)
106:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.