Class: ActiveRecord::ConnectionAdapters::TableDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/railstar/column_comment.rb

Instance Method Summary collapse

Instance Method Details

#column(name, type, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/railstar/column_comment.rb', line 5

def column(name, type, options = {})
  name = name.to_s
  type = type.to_sym
 
  column = self[name] || new_column_definition(@base, name, type)                                                                                                                                                                                                     
 
  limit = options.fetch(:limit) do
    native[type][:limit] if native[type].is_a?(Hash)
  end
 
  column.limit     = limit
  column.precision = options[:precision]
  column.scale     = options[:scale]
  column.default   = options[:default]
  column.null      = options[:null]
  column.comment   = options[:comment]
  self
end