Class: TenantCheck::Notification

Inherits:
Object
  • Object
show all
Defined in:
lib/tenant_check/notification.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(callers, base_class, sql) ⇒ Notification

Returns a new instance of Notification.



9
10
11
12
13
14
# File 'lib/tenant_check/notification.rb', line 9

def initialize(callers, base_class, sql)
  @callers = callers
  @filtered_callers = StackTraceFilter.filter_in_project(callers)
  @base_class = base_class
  @sql = sql
end

Instance Attribute Details

#base_classObject (readonly)

Returns the value of attribute base_class.



7
8
9
# File 'lib/tenant_check/notification.rb', line 7

def base_class
  @base_class
end

#callersObject (readonly)

Returns the value of attribute callers.



7
8
9
# File 'lib/tenant_check/notification.rb', line 7

def callers
  @callers
end

#filtered_callersObject (readonly)

Returns the value of attribute filtered_callers.



7
8
9
# File 'lib/tenant_check/notification.rb', line 7

def filtered_callers
  @filtered_callers
end

#sqlObject (readonly)

Returns the value of attribute sql.



7
8
9
# File 'lib/tenant_check/notification.rb', line 7

def sql
  @sql
end

Instance Method Details

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/tenant_check/notification.rb', line 20

def eql?(other)
  base_class == other.base_class && callers == other.callers
end

#filtered_callers_or_callersObject



16
17
18
# File 'lib/tenant_check/notification.rb', line 16

def filtered_callers_or_callers
  filtered_callers.empty? ? callers : filtered_callers
end

#hashObject



24
25
26
# File 'lib/tenant_check/notification.rb', line 24

def hash
  [base_class, callers].hash
end

#messageObject



28
29
30
31
32
33
34
35
36
37
# File 'lib/tenant_check/notification.rb', line 28

def message
  <<~EOS
    >>> Query without tenant condition detected!
    class: #{base_class}
    sql: #{sql}
    stacktrace:
    #{filtered_callers_or_callers.join("\n")}

  EOS
end