Class: Flydata::Parser::SourceTable

Inherits:
Object
  • Object
show all
Defined in:
lib/flydata/parser/source_table.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table_name, columns = {}) ⇒ SourceTable

Returns a new instance of SourceTable.



5
6
7
8
9
10
11
12
# File 'lib/flydata/parser/source_table.rb', line 5

def initialize(table_name, columns = {})
  @table_name = table_name
  @columns = columns
  @column_names = columns.collect{|k,v| v[:column_name]}
  @primary_keys = [] # no longer used.  keeping the instance variable for
                     # mashall dump compatibility
  @value_converters = {}
end

Instance Attribute Details

#column_namesObject

Returns the value of attribute column_names.



14
15
16
# File 'lib/flydata/parser/source_table.rb', line 14

def column_names
  @column_names
end

#table_nameObject

Returns the value of attribute table_name.



14
15
16
# File 'lib/flydata/parser/source_table.rb', line 14

def table_name
  @table_name
end

#value_convertersObject

Returns the value of attribute value_converters.



14
15
16
# File 'lib/flydata/parser/source_table.rb', line 14

def value_converters
  @value_converters
end

Instance Method Details

#add_column(column) ⇒ Object



16
17
18
19
20
# File 'lib/flydata/parser/source_table.rb', line 16

def add_column(column)
  cn = column[:column_name]
  @columns[cn] = column
  @column_names << cn
end

#set_value_converters(converter_hash) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/flydata/parser/source_table.rb', line 22

def set_value_converters(converter_hash)
  @value_converters ||= {}  # for backward compatibility with an old marshal dump object
  @columns.each_with_index do |(k, v), i|
    type = v[:format_type]
    if converter_hash.has_key?(type)
      @value_converters[i] = converter_hash[type]
    end
  end
end