Class: JunglePath::Gen::SchemaTree::Filter
- Inherits:
-
Object
- Object
- JunglePath::Gen::SchemaTree::Filter
- Defined in:
- lib/jungle_path/gen/schema_tree/filter.rb
Instance Method Summary collapse
- #allow?(table_name, column_name = nil) ⇒ Boolean
-
#initialize(hash = nil) ⇒ Filter
constructor
A new instance of Filter.
Constructor Details
#initialize(hash = nil) ⇒ Filter
Returns a new instance of Filter.
6 7 8 9 10 11 12 |
# 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 |
Instance Method Details
#allow?(table_name, column_name = nil) ⇒ Boolean
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/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 |