class Lev::Error
Attributes
code[RW]
data[RW]
kind[RW]
message[RW]
offending_inputs[RW]
The inputs related to this error
Public Class Methods
new(args={})
click to toggle source
# File lib/lev/error.rb, line 13 def initialize(args={}) raise ArgumentError, "must supply a :code" if args[:code].blank? self.code = args[:code] self.data = args[:data] self.kind = args[:kind] self.message = args[:message] self.offending_inputs = args[:offending_inputs] end
Public Instance Methods
full_message()
click to toggle source
# File lib/lev/error.rb, line 31 def full_message attribute = data[:attribute] if data.present? return message.humanize if attribute.nil? attr_name = attribute.to_s.gsub('.', '_').humanize model = data[:model] attr_name = model.class.human_attribute_name(attribute, default: attr_name) if model.present? I18n.t(:"errors.format", { default: "%{attribute} %{message}", attribute: attr_name, message: message }) end
to_s()
click to toggle source
# File lib/lev/error.rb, line 27 def to_s inspect end
translate()
click to toggle source
# File lib/lev/error.rb, line 23 def translate ErrorTranslator.translate(self) end