Class: MysqlInspector::Column
- Inherits:
-
Struct
- Object
- Struct
- MysqlInspector::Column
- Includes:
- TablePart
- Defined in:
- lib/mysql_inspector/column.rb
Instance Attribute Summary collapse
-
#auto_increment ⇒ Object
Returns the value of attribute auto_increment.
-
#default ⇒ Object
Returns the value of attribute default.
-
#name ⇒ Object
Returns the value of attribute name.
-
#nullable ⇒ Object
Returns the value of attribute nullable.
-
#sql_type ⇒ Object
Returns the value of attribute sql_type.
Attributes included from TablePart
Instance Method Summary collapse
Methods included from TablePart
Instance Attribute Details
#auto_increment ⇒ Object
Returns the value of attribute auto_increment
2 3 4 |
# File 'lib/mysql_inspector/column.rb', line 2 def auto_increment @auto_increment end |
#default ⇒ Object
Returns the value of attribute default
2 3 4 |
# File 'lib/mysql_inspector/column.rb', line 2 def default @default end |
#name ⇒ Object
Returns the value of attribute name
2 3 4 |
# File 'lib/mysql_inspector/column.rb', line 2 def name @name end |
#nullable ⇒ Object
Returns the value of attribute nullable
2 3 4 |
# File 'lib/mysql_inspector/column.rb', line 2 def nullable @nullable end |
#sql_type ⇒ Object
Returns the value of attribute sql_type
2 3 4 |
# File 'lib/mysql_inspector/column.rb', line 2 def sql_type @sql_type end |
Instance Method Details
#=~(matcher) ⇒ Object
16 17 18 |
# File 'lib/mysql_inspector/column.rb', line 16 def =~(matcher) name =~ matcher end |
#to_sql ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/mysql_inspector/column.rb', line 6 def to_sql parts = [] parts << quote(name) parts << sql_type parts << (nullable ? "NULL" : "NOT NULL") parts << "DEFAULT #{default}" if default parts << "AUTO_INCREMENT" if auto_increment parts * " " end |