Sha256: 98a27361a61ad3f23fe00b6141d82ca7ffe4a1cbd82f6057c9eb1284f9cb3b86

Contents?: true

Size: 420 Bytes

Versions: 3

Compression:

Stored size: 420 Bytes

Contents

module Lev

  class ErrorTranslator

    def self.translate(error)
      case error.kind
      when :activerecord
        attribute = error.data[:attribute]
        message = error.message
        model = error.data[:model]
        ActiveModel::Error.full_message(attribute, message, model)
      else
        message = error.message.to_s
        message.empty? ? error.code.to_s : message
      end
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lev-12.1.0 lib/lev/error_translator.rb
lev-12.0.0 lib/lev/error_translator.rb
lev-11.0.0 lib/lev/error_translator.rb