Class: PgDiff::Attribute

Inherits:
Object
  • Object
show all
Defined in:
lib/attribute.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, typedef, notnull, default) ⇒ Attribute

Returns a new instance of Attribute.



5
6
7
8
9
10
# File 'lib/attribute.rb', line 5

def initialize(name, typedef, notnull, default)
  @name = name
  @type_def = typedef
  @notnull = notnull
  @default = default
end

Instance Attribute Details

#defaultObject

Returns the value of attribute default.



3
4
5
# File 'lib/attribute.rb', line 3

def default
  @default
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/attribute.rb', line 3

def name
  @name
end

#notnullObject

Returns the value of attribute notnull.



3
4
5
# File 'lib/attribute.rb', line 3

def notnull
  @notnull
end

#type_defObject

Returns the value of attribute type_def.



3
4
5
# File 'lib/attribute.rb', line 3

def type_def
  @type_def
end

Instance Method Details

#==(other) ⇒ Object



19
20
21
# File 'lib/attribute.rb', line 19

def == (other)
  definition == other.definition
end

#definitionObject



12
13
14
15
16
17
# File 'lib/attribute.rb', line 12

def definition
  out = ['    ', @name,  @type_def]
  out << 'NOT NULL' if @notnull
  out << 'DEFAULT ' + @default if @default
  out.join(" ")
end