class JunglePath::Gen::SchemaTree::MatchTables
Public Class Methods
new(data)
click to toggle source
# 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
Public Instance Methods
includes_columns?(table_name)
click to toggle source
# 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)
click to toggle source
# 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_s()
click to toggle source
# File lib/jungle_path/gen/schema_tree/match_tables.rb, line 54 def to_s "@hash: #{@hash}\n@match_data: #{@match_data}." end
Private Instance Methods
get_match_table_data(table_name)
click to toggle source
# File lib/jungle_path/gen/schema_tree/match_tables.rb, line 60 def get_match_table_data table_name match_table_data = @hash[table_name.to_sym] return match_table_data if match_table_data @match_data.each do |mtd| return mtd if mtd.regexp =~ table_name.to_s end nil end