Class: Baza::Column

Inherits:
Object
  • Object
show all
Includes:
DatabaseModelFunctionality
Defined in:
lib/baza/column.rb

Instance Method Summary collapse

Methods included from DatabaseModelFunctionality

#model_name, #to_model

Instance Method Details

#afterObject



20
21
22
23
24
25
26
27
28
# File 'lib/baza/column.rb', line 20

def after
  last = nil
  table.columns.each do |column|
    break if column.name == name
    last = column.name
  end

  last
end

#dataObject



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/baza/column.rb', line 30

def data
  {
    type: type,
    name: name,
    null: null?,
    maxlength: maxlength,
    default: default,
    primarykey: primarykey?,
    autoincr: autoincr?
  }
end

#inspectObject



8
9
10
# File 'lib/baza/column.rb', line 8

def inspect
  to_s
end

#tableObject



16
17
18
# File 'lib/baza/column.rb', line 16

def table
  @db.tables[table_name]
end

#to_paramObject



12
13
14
# File 'lib/baza/column.rb', line 12

def to_param
  name
end

#to_sObject



4
5
6
# File 'lib/baza/column.rb', line 4

def to_s
  "#<#{self.class.name} name=\"#{name}\" type=\"#{type}\" maxlength=\"#{maxlength}\" autoincr=\"#{autoincr?}\" primarykey=\"#{primarykey?}\">"
end