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

Returns a new instance of 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



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

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

Instance Method Details

#destination_nameObject



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

def destination_name
  "lhmn_#{ @name }"
end

#satisfies_primary_key?Boolean

Returns:

  • (Boolean)


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

def satisfies_primary_key?
  @pk == 'id'
end