Class: SqlServerSchemaReflector::ColumnReflection
- Inherits:
-
Object
- Object
- SqlServerSchemaReflector::ColumnReflection
- Defined in:
- lib/sqlserver_schema_reflector/column_reflection.rb
Instance Attribute Summary collapse
-
#identity ⇒ Object
readonly
Returns the value of attribute identity.
Instance Method Summary collapse
- #id_statement ⇒ Object
-
#initialize(properties, identity = nil) ⇒ ColumnReflection
constructor
A new instance of ColumnReflection.
- #length ⇒ Object
- #name ⇒ Object
- #nullable ⇒ Object
- #sql ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(properties, identity = nil) ⇒ ColumnReflection
Returns a new instance of ColumnReflection.
3 4 5 6 7 8 |
# File 'lib/sqlserver_schema_reflector/column_reflection.rb', line 3 def initialize(properties, identity = nil) @properties = properties if identity[:identity] === properties[:column_name] @identity = identity unless identity.nil? end end |
Instance Attribute Details
#identity ⇒ Object (readonly)
Returns the value of attribute identity.
2 3 4 |
# File 'lib/sqlserver_schema_reflector/column_reflection.rb', line 2 def identity @identity end |
Instance Method Details
#id_statement ⇒ Object
23 24 25 |
# File 'lib/sqlserver_schema_reflector/column_reflection.rb', line 23 def id_statement "IDENTITY(#{@identity[:seed]},#{@identity[:increment]})" unless @identity.nil? end |
#length ⇒ Object
15 16 17 |
# File 'lib/sqlserver_schema_reflector/column_reflection.rb', line 15 def length "(#{@properties[:length]})" unless @properties[:length].nil? || type === 'int' end |
#name ⇒ Object
9 10 11 |
# File 'lib/sqlserver_schema_reflector/column_reflection.rb', line 9 def name @properties[:column_name] end |
#nullable ⇒ Object
18 19 20 21 22 |
# File 'lib/sqlserver_schema_reflector/column_reflection.rb', line 18 def nullable _nullable = "NOT NULL" _nullable = "NULL" if @properties[:nullable] === 'yes' _nullable end |
#sql ⇒ Object
26 27 28 |
# File 'lib/sqlserver_schema_reflector/column_reflection.rb', line 26 def sql "[#{name}] [#{type}]#{length} #{id_statement} #{nullable}" end |
#type ⇒ Object
12 13 14 |
# File 'lib/sqlserver_schema_reflector/column_reflection.rb', line 12 def type @properties[:type] end |