class JunglePath::Gen::SchemaTree::Filter

Public Class Methods

new(hash=nil) click to toggle source
# File lib/jungle_path/gen/schema_tree/filter.rb, line 6
def initialize hash=nil
        throw "Invalid data parameter: expected a hash, but got this: #{hash}" unless hash.class == Hash or hash == nil
        allow = hash[:allow] if hash
        deny = hash[:deny] if hash
        @match_tables_allow = JunglePath::Gen::SchemaTree::MatchTables.new allow
        @match_tables_deny = JunglePath::Gen::SchemaTree::MatchTables.new deny
end

Public Instance Methods

allow?(table_name, column_name=nil) click to toggle source
# File lib/jungle_path/gen/schema_tree/filter.rb, line 13
def allow? table_name, column_name=nil
        if @match_tables_allow.matched?(table_name, column_name)
                if column_name and @match_tables_deny.matched?(table_name, column_name)
                        return false
                end
                if column_name and !@match_tables_deny.matched?(table_name, column_name)
                        return true
                end
                if !column_name and @match_tables_deny.matched?(table_name) and !@match_tables_deny.includes_columns?(table_name)
                        return false
                end
                if !column_name and @match_tables_deny.includes_columns?(table_name)
                        return true
                end
                return true
        end
        false
end