Class: XMigra::DeclarativeSupport::Table::Column
- Defined in:
- lib/xmigra/declarative_support/table.rb
Constant Summary collapse
- SPEC_ATTRS =
[:name, :type]
Instance Attribute Summary collapse
-
#default_constraint ⇒ Object
Returns the value of attribute default_constraint.
Instance Method Summary collapse
-
#initialize(col_spec) ⇒ Column
constructor
A new instance of Column.
- #nullable=(value) ⇒ Object
- #nullable? ⇒ Boolean
- #primary_key=(value) ⇒ Object
- #primary_key? ⇒ Boolean
Constructor Details
#initialize(col_spec) ⇒ Column
Returns a new instance of Column.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/xmigra/declarative_support/table.rb', line 75 def initialize(col_spec) @primary_key = !!col_spec['primary key'] @nullable = !!col_spec.fetch('nullable', true) SPEC_ATTRS.each do |a| instance_variable_set("@#{a}".to_sym, col_spec[a.to_s]) end if default = col_spec['default'] @default_constraint = DefaultConstraint.new( "DF_#{name}", StructureReader.new({ 'column'=>name, 'value'=>default }) ) end end |
Instance Attribute Details
#default_constraint ⇒ Object
Returns the value of attribute default_constraint.
93 94 95 |
# File 'lib/xmigra/declarative_support/table.rb', line 93 def default_constraint @default_constraint end |
Instance Method Details
#nullable=(value) ⇒ Object
105 106 107 |
# File 'lib/xmigra/declarative_support/table.rb', line 105 def nullable=(value) @nullable = value end |
#nullable? ⇒ Boolean
102 103 104 |
# File 'lib/xmigra/declarative_support/table.rb', line 102 def nullable? @nullable end |
#primary_key=(value) ⇒ Object
98 99 100 |
# File 'lib/xmigra/declarative_support/table.rb', line 98 def primary_key=(value) @primary_key = value end |
#primary_key? ⇒ Boolean
95 96 97 |
# File 'lib/xmigra/declarative_support/table.rb', line 95 def primary_key? @primary_key end |