Class: WhinyValidation::LogSubscriber

Inherits:
ActiveSupport::LogSubscriber
  • Object
show all
Defined in:
lib/whiny_validation.rb

Instance Method Summary collapse

Instance Method Details

#validation_failed(event) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/whiny_validation.rb', line 21

def validation_failed(event)
  send(WhinyValidation.configuration.log_level) do
    name = color("Validation failed", YELLOW, true)
    object = event.payload[:object]
    error_messages = color(event.payload[:error_messages].map{|message|"    => #{message}"}.join("\n"), YELLOW)

    "  #{name}  #{object.inspect}\n#{error_messages}"
  end
end