Class: RubyPgExtras::IgnoreList

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_pg_extras/ignore_list.rb

Overview

Parses and matches ignore patterns like:

  • “*” (ignore everything)

  • “posts.*” (ignore all columns on a table)

  • “category_id” (ignore this column name on all tables)

  • “posts.topic_id” (ignore a specific table+column)

Instance Method Summary collapse

Constructor Details

#initialize(ignore_list) ⇒ IgnoreList

Returns a new instance of IgnoreList.



10
11
12
# File 'lib/ruby_pg_extras/ignore_list.rb', line 10

def initialize(ignore_list)
  @rules = normalize(ignore_list)
end

Instance Method Details

#ignored?(table:, column_name:) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
18
19
20
21
22
# File 'lib/ruby_pg_extras/ignore_list.rb', line 14

def ignored?(table:, column_name:)
  @rules.any? do |rule|
    next true if rule == "*"
    next true if rule == "#{table}.*"
    next true if rule == column_name
    next true if rule == "#{table}.#{column_name}"
    false
  end
end