Class: XMigra::DeclarativeSupport::Table::DefaultConstraint
- Inherits:
-
Constraint
- Object
- Constraint
- XMigra::DeclarativeSupport::Table::DefaultConstraint
- Defined in:
- lib/xmigra/declarative_support/table.rb
Constant Summary collapse
- IDENTIFIER =
'default'
- IMPLICIT_PREFIX =
'DF_'
Constants inherited from Constraint
Instance Attribute Summary collapse
-
#column ⇒ Object
Returns the value of attribute column.
-
#expression ⇒ Object
Returns the value of attribute expression.
Attributes inherited from Constraint
Instance Method Summary collapse
- #creation_sql ⇒ Object
-
#initialize(name, constr_spec) ⇒ DefaultConstraint
constructor
A new instance of DefaultConstraint.
- #only_on_column_at_creation? ⇒ Boolean
Methods inherited from Constraint
bad_spec, #constraint_type, deserialize, each_type, implicit_type, inherited, type_by_identifier
Constructor Details
#initialize(name, constr_spec) ⇒ DefaultConstraint
Returns a new instance of DefaultConstraint.
296 297 298 299 300 301 302 303 304 305 306 307 |
# File 'lib/xmigra/declarative_support/table.rb', line 296 def initialize(name, constr_spec) super(name, constr_spec) implicit_column = ( name[IMPLICIT_PREFIX.length..-1] if name.start_with?(IMPLICIT_PREFIX) ) @column = constr_spec['column'] || implicit_column || Constraint.bad_spec( %Q{Default constraint #{name} does not specify a "column"} ) @expression = constr_spec['value'] || Constraint.bad_spec( %Q{Default constraint #{name} does not specify an expression to use as a "value"} ) end |
Instance Attribute Details
#column ⇒ Object
Returns the value of attribute column.
309 310 311 |
# File 'lib/xmigra/declarative_support/table.rb', line 309 def column @column end |
#expression ⇒ Object
Returns the value of attribute expression.
309 310 311 |
# File 'lib/xmigra/declarative_support/table.rb', line 309 def expression @expression end |
Instance Method Details
#creation_sql ⇒ Object
315 316 317 |
# File 'lib/xmigra/declarative_support/table.rb', line 315 def creation_sql creation_name_sql + "DEFAULT #{expression} FOR #{column}" end |
#only_on_column_at_creation? ⇒ Boolean
311 312 313 |
# File 'lib/xmigra/declarative_support/table.rb', line 311 def only_on_column_at_creation? true end |