class DTK::ErrorConstraintViolations
Public Class Methods
new(violations)
click to toggle source
Calls superclass method
DTK::Error::new
# File lib/errors/errors.rb, line 65 def initialize(violations) super(msg(violations),:ConstraintViolations) end
Private Instance Methods
msg(violations)
click to toggle source
# File lib/errors/errors.rb, line 69 def msg(violations) return ("constraint violation: " + violations) if violations.kind_of?(String) v_with_text = violations.compact if v_with_text.size < 2 return "constraint violations" elsif v_with_text.size == 2 return "constraint violations: #{v_with_text[1]}" end ret = "constraint violations: " ret << (v_with_text.first == :or ? "(atleast) one of " : "") ret << "(#{v_with_text[1..v_with_text.size-1].join(", ")})" end