Class: Squirm::Migrator::Column
- Inherits:
-
Object
- Object
- Squirm::Migrator::Column
- Defined in:
- lib/squirm/migrator/column.rb
Defined Under Namespace
Classes: Type
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #definition ⇒ Object
-
#initialize(name) ⇒ Column
constructor
A new instance of Column.
- #quoted_name ⇒ Object
- #templates ⇒ Object
- #to_sql ⇒ Object
- #type ⇒ Object
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
#name ⇒ Object (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
#definition ⇒ Object
42 43 44 |
# File 'lib/squirm/migrator/column.rb', line 42 def definition type.definition end |
#quoted_name ⇒ Object
34 35 36 |
# File 'lib/squirm/migrator/column.rb', line 34 def quoted_name Squirm.quote_ident name end |
#templates ⇒ Object
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_sql ⇒ Object
46 47 48 |
# File 'lib/squirm/migrator/column.rb', line 46 def to_sql "#{quoted_name} #{definition}" end |
#type ⇒ Object
38 39 40 |
# File 'lib/squirm/migrator/column.rb', line 38 def type @type ||= Type.by_priority.first {|type| type =~ name} end |