Class: JunglePath::Gen::SchemaTree::MatchTables

Inherits:
Object
  • Object
show all
Defined in:
lib/jungle_path/gen/schema_tree/match_tables.rb

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ MatchTables

Returns a new instance of MatchTables.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/jungle_path/gen/schema_tree/match_tables.rb', line 6

def initialize data
  @hash = {}
  @match_data = []
  throw "Invalid data parameter: expected an array, but got this: #{data}" unless data.class == Array or data == nil
  if data
    data.each do |h|
      if h.class == Hash
        table = h[:table]
        puts "table: #{table}."
        columns = h[:columns]
        puts "columns: #{columns}."
        if table
          mtd = JunglePath::Gen::SchemaTree::MatchTableData.new(table, columns)
          puts "mtd: #{mtd}."
          @hash[mtd.name] = mtd
          @match_data << mtd if mtd.regexp
        else
          throw "Invalid hash -- missing key :table. Got this: #{h}."
        end
      else
        throw "Invalid data item. Expected hash got this: #{h}."
      end
    end
  end
end

Instance Method Details

#includes_columns?(table_name) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
49
50
51
52
# File 'lib/jungle_path/gen/schema_tree/match_tables.rb', line 46

def includes_columns? table_name
  if table_name
    match_table_data = get_match_table_data(table_name)
    return !match_table_data.nil_columns? if match_table_data
  end
  false
end

#matched?(table_name, column_name = nil) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/jungle_path/gen/schema_tree/match_tables.rb', line 32

def matched? table_name, column_name=nil
  if table_name
    match_table_data = get_match_table_data(table_name)
    if match_table_data
      if column_name
        return match_table_data.columns.matched?(column_name)
      else
        return true
      end
    end
  end
  false
end

#to_sObject



54
55
56
# File 'lib/jungle_path/gen/schema_tree/match_tables.rb', line 54

def to_s
  "@hash: #{@hash}\n@match_data: #{@match_data}."
end