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.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/xmigra/declarative_support/table.rb', line 81 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.
99 100 101 |
# File 'lib/xmigra/declarative_support/table.rb', line 99 def default_constraint @default_constraint end |
Instance Method Details
#nullable=(value) ⇒ Object
111 112 113 |
# File 'lib/xmigra/declarative_support/table.rb', line 111 def nullable=(value) @nullable = value end |
#nullable? ⇒ Boolean
108 109 110 |
# File 'lib/xmigra/declarative_support/table.rb', line 108 def nullable? @nullable end |
#primary_key=(value) ⇒ Object
104 105 106 |
# File 'lib/xmigra/declarative_support/table.rb', line 104 def primary_key=(value) @primary_key = value end |
#primary_key? ⇒ Boolean
101 102 103 |
# File 'lib/xmigra/declarative_support/table.rb', line 101 def primary_key? @primary_key end |