Class: Dbsketch::Model::Column

Inherits:
AbstractColumn show all
Defined in:
lib/dbsketch/model/column.rb

Instance Attribute Summary collapse

Attributes inherited from AbstractColumn

#nullable, #order

Attributes inherited from Database_Object

#comment, #dependencies, #meaning, #name, #order

Instance Method Summary collapse

Methods inherited from Database_Object

#add_dependencies, #class_name, #compute_order!, #inspect, #reset_order!

Constructor Details

#initialize(name, type, meaning: nil, comment: nil, nullable: true, order: nil, identity: false, default: nil) ⇒ Column

Returns a new instance of Column.

Raises:

  • (ArgumentError)


12
13
14
15
16
17
18
19
20
21
# File 'lib/dbsketch/model/column.rb', line 12

def initialize name, type, meaning: nil, comment: nil, nullable: true, order: nil, identity: false, default: nil
	super(name, :meaning => meaning, :comment => comment, :nullable => nullable, :order => order)
	### Preconditions
	raise ArgumentError, "type is not a Dbsketch::Model::Type" unless type.is_a? Dbsketch::Model::Type
	raise ArgumentError, "identity is not a boolean" unless identity.is_a? TrueClass or identity.is_a? FalseClass
	###
	@type = type
	@identity = identity
	@default = default
end

Instance Attribute Details

#defaultObject

Returns the value of attribute default.



23
24
25
# File 'lib/dbsketch/model/column.rb', line 23

def default
  @default
end

#identityObject (readonly)

Returns the value of attribute identity.



23
24
25
# File 'lib/dbsketch/model/column.rb', line 23

def identity
  @identity
end

#typeObject (readonly)

Returns the value of attribute type.



23
24
25
# File 'lib/dbsketch/model/column.rb', line 23

def type
  @type
end

Instance Method Details

#compatible_with?(other_column) ⇒ Boolean

Returns:

  • (Boolean)

Raises:

  • (ArgumentError)


26
27
28
29
30
31
# File 'lib/dbsketch/model/column.rb', line 26

def compatible_with? other_column
	### Preconditions
	raise ArgumentError, "other_column is not a Dbsketch::Model::Column" unless other_column.is_a? Column
	###
	(@type.compatible_with? other_column.type) and (not @nullable or other_column.nullable)
end