Class: MetaDb::Column
Instance Attribute Summary collapse
-
#default ⇒ Object
readonly
Default value.
-
#ordinal ⇒ Object
readonly
Ordinal number of the column.
-
#type ⇒ Object
readonly
Type of the column.
Attributes inherited from DbObject
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Compare columns by table and ordinal.
-
#generated? ⇒ Boolean
True if column is auto generated.
-
#identity? ⇒ Boolean
True if column is an identity column.
-
#initialize(table, ordinal, name, type, default, is_identity, is_generated, is_nullable, is_updatable) ⇒ Column
constructor
A new instance of Column.
-
#nullable? ⇒ Boolean
True if column is nullable.
-
#primary_key? ⇒ Boolean
True if column is the single primary key of the table.
-
#primary_key_column? ⇒ Boolean
True is column is (part of) the primary key of the table.
-
#updatable? ⇒ Boolean
True if column is updatable.
Methods inherited from DbObject
#[], attrs, #dot, #dump, #dump_attrs, init, #inspect, #path
Constructor Details
#initialize(table, ordinal, name, type, default, is_identity, is_generated, is_nullable, is_updatable) ⇒ Column
Returns a new instance of Column.
247 248 249 250 251 |
# File 'lib/meta_db/db_object.rb', line 247 def initialize(table, ordinal, name, type, default, is_identity, is_generated, is_nullable, is_updatable) super(table, name) @type, @ordinal, @default, @is_identity, @is_generated, @is_nullable, @is_updatable = type, ordinal, default, is_identity, is_generated, is_nullable, is_updatable end |
Instance Attribute Details
#default ⇒ Object (readonly)
Default value
226 227 228 |
# File 'lib/meta_db/db_object.rb', line 226 def default @default end |
#ordinal ⇒ Object (readonly)
Ordinal number of the column
220 221 222 |
# File 'lib/meta_db/db_object.rb', line 220 def ordinal @ordinal end |
#type ⇒ Object (readonly)
Type of the column
223 224 225 |
# File 'lib/meta_db/db_object.rb', line 223 def type @type end |
Instance Method Details
#<=>(other) ⇒ Object
Compare columns by table and ordinal
254 255 256 257 258 259 260 |
# File 'lib/meta_db/db_object.rb', line 254 def <=>(other) if other.is_a?(Column) && table == other.table ordinal <=> other.ordinal else super end end |
#generated? ⇒ Boolean
True if column is auto generated
232 |
# File 'lib/meta_db/db_object.rb', line 232 def generated?() @is_generated end |
#identity? ⇒ Boolean
True if column is an identity column
229 |
# File 'lib/meta_db/db_object.rb', line 229 def identity?() @is_identity end |
#nullable? ⇒ Boolean
True if column is nullable
235 |
# File 'lib/meta_db/db_object.rb', line 235 def nullable?() @is_nullable end |
#primary_key? ⇒ Boolean
True if column is the single primary key of the table. Always false for tables with multiple primary keys
242 |
# File 'lib/meta_db/db_object.rb', line 242 def primary_key?() table.table? && self == table.primary_key_column end |
#primary_key_column? ⇒ Boolean
True is column is (part of) the primary key of the table
245 |
# File 'lib/meta_db/db_object.rb', line 245 def primary_key_column?() table.table? && table.primary_key_columns.include?(self) end |
#updatable? ⇒ Boolean
True if column is updatable
238 |
# File 'lib/meta_db/db_object.rb', line 238 def updatable?() @is_updatable end |