Method: Twb::DbField#initialize

Defined in:
lib/twb/dbfield.rb

#initialize(dataSource, node, nodeType, table = nil) ⇒ DbField

Returns a new instance of DbField.



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/twb/dbfield.rb', line 29

def initialize dataSource, node, nodeType, table=nil
  @node     = node
  @nodeType = nodeType
  case @nodeType
    when :map
      @uiname  = @node.attribute('key').text.gsub(/^\[|\]$/,'')
      @name    = @uiname
      fldRef   = @node.attribute('value').text.gsub(/^\[|\]$/,'')
      parts    = fldRef.split('].[')
      @dbtable = parts[0]
      @dbname  = parts[1]
    when :tableColumn
      @uiname  = @node.attribute('name').text
      @name    = @uiname
      @dbtable = table
    else
      raise ArgumentError.new("ERROR in DbField creation: invalid Node type, is #{nodeType} \n ")
  end      
  @id      = "#{dataSource}::#{dbname}::#{dbtable}::#{uiname}"
end