Class: Squirm::Migrator::Column

Inherits:
Object
  • Object
show all
Defined in:
lib/squirm/migrator/column.rb

Defined Under Namespace

Classes: Type

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Column

Returns a new instance of Column.



30
31
32
# File 'lib/squirm/migrator/column.rb', line 30

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



28
29
30
# File 'lib/squirm/migrator/column.rb', line 28

def name
  @name
end

Instance Method Details

#definitionObject



42
43
44
# File 'lib/squirm/migrator/column.rb', line 42

def definition
  type.definition
end

#quoted_nameObject



34
35
36
# File 'lib/squirm/migrator/column.rb', line 34

def quoted_name
  Squirm.quote_ident name
end

#templatesObject



50
51
52
53
54
55
56
# File 'lib/squirm/migrator/column.rb', line 50

def templates
  @templates ||= begin
    @templates = type.templates.map do |template|
      Template.from_path "#{template}.sql.erb", :column => self
    end
  end
end

#to_sqlObject



46
47
48
# File 'lib/squirm/migrator/column.rb', line 46

def to_sql
  "#{quoted_name} #{definition}"
end

#typeObject



38
39
40
# File 'lib/squirm/migrator/column.rb', line 38

def type
  @type ||= Type.by_priority.first {|type| type =~ name}
end