Class: Lhm::Table

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

Defined Under Namespace

Classes: Parser

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, pk = 'id', ddl = nil) ⇒ Table


10
11
12
13
14
15
16
# File 'lib/lhm/table.rb', line 10

def initialize(name, pk = 'id', ddl = nil)
  @name = name
  @columns = {}
  @indices = {}
  @pk = pk
  @ddl = ddl
end

Instance Attribute Details

#columnsObject (readonly)

Returns the value of attribute columns


8
9
10
# File 'lib/lhm/table.rb', line 8

def columns
  @columns
end

#ddlObject (readonly)

Returns the value of attribute ddl


8
9
10
# File 'lib/lhm/table.rb', line 8

def ddl
  @ddl
end

#indicesObject (readonly)

Returns the value of attribute indices


8
9
10
# File 'lib/lhm/table.rb', line 8

def indices
  @indices
end

#nameObject (readonly)

Returns the value of attribute name


8
9
10
# File 'lib/lhm/table.rb', line 8

def name
  @name
end

#pkObject (readonly)

Returns the value of attribute pk


8
9
10
# File 'lib/lhm/table.rb', line 8

def pk
  @pk
end

Class Method Details

.parse(table_name, connection) ⇒ Object


27
28
29
# File 'lib/lhm/table.rb', line 27

def self.parse(table_name, connection)
  Parser.new(table_name, connection).parse
end

Instance Method Details

#destination_nameObject


23
24
25
# File 'lib/lhm/table.rb', line 23

def destination_name
  "lhmn_#{ @name }"
end

#satisfies_id_column_requirement?Boolean


18
19
20
21
# File 'lib/lhm/table.rb', line 18

def satisfies_id_column_requirement?
  !!((id = columns['id']) &&
    id[:type] =~ /(bigint|int)\(\d+\)/)
end