Class: WipeOut::Validators::Attributes

Inherits:
Base
  • Object
show all
Defined in:
lib/wipe_out/validators/attributes.rb

Instance Method Summary collapse

Instance Method Details

#callObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/wipe_out/validators/attributes.rb', line 4

def call
  return if ignored?

  if missing_attributes.any?
    names = missing_attributes.map { |name| ":#{name}" }.join(", ")

    result.add_error("#{ar_class.name} plan is missing attributes: #{names}")
  end

  if non_existing_attributes.any?
    names = non_existing_attributes.map { |name| ":#{name}" }.join(", ")

    result.add_error("#{ar_class.name} plan has extra attributes: #{names}")
  end
end