Class: SQL::TableCreator::Column
- Inherits:
-
Object
- Object
- SQL::TableCreator::Column
- Defined in:
- lib/sql/table_creator.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #build_type(type_class) ⇒ Object
-
#initialize(adapter, name, type, opts = {}) ⇒ Column
constructor
A new instance of Column.
- #quoted_name ⇒ Object
- #to_sql ⇒ Object
Constructor Details
#initialize(adapter, name, type, opts = {}) ⇒ Column
Returns a new instance of Column.
30 31 32 33 34 35 |
# File 'lib/sql/table_creator.rb', line 30 def initialize(adapter, name, type, opts = {}) @adapter = adapter @name = name.to_s @opts = opts @type = build_type(type) end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
28 29 30 |
# File 'lib/sql/table_creator.rb', line 28 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
28 29 30 |
# File 'lib/sql/table_creator.rb', line 28 def type @type end |
Instance Method Details
#build_type(type_class) ⇒ Object
37 38 39 40 41 |
# File 'lib/sql/table_creator.rb', line 37 def build_type(type_class) schema = {:name => @name, :quote_column_name => quoted_name}.merge(@opts) schema = @adapter.class.type_map[type_class].merge(schema) @adapter.property_schema_statement(schema) end |
#quoted_name ⇒ Object
47 48 49 |
# File 'lib/sql/table_creator.rb', line 47 def quoted_name @adapter.send(:quote_column_name, name) end |
#to_sql ⇒ Object
43 44 45 |
# File 'lib/sql/table_creator.rb', line 43 def to_sql type end |