Class: TableWarnings::NonexistentOwner

Inherits:
Exclusive
  • Object
show all
Defined in:
lib/table_warnings/nonexistent_owner.rb

Instance Attribute Summary

Attributes inherited from Exclusive

#conditions, #scout, #table

Instance Method Summary collapse

Methods inherited from Exclusive

#covers, #exclusives, #matches, #messages

Constructor Details

#initialize(table, matcher, options = {}) ⇒ NonexistentOwner

Returns a new instance of NonexistentOwner.



3
4
5
6
7
# File 'lib/table_warnings/nonexistent_owner.rb', line 3

def initialize(table, matcher, options = {})
  super
  scout.enable_association_check!
  @allow_null_query = options[:allow_null]
end

Instance Method Details

#message(column) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/table_warnings/nonexistent_owner.rb', line 9

def message(column)
  if column.nonexistent_owners?(conditions) or (not allow_null? and column.nulls?(conditions))
    if conditions.empty?
      "Values in foreign key column #{column.name.inspect}#{null_warning} do not correspond to actual values in foreign table."
    else
      "Values in foreign key column #{column.name.inspect} under condition #{conditions.inspect}#{null_warning} do not correspond to actual values in foreign table."
    end
  end
end