Sha256: e41d5634e99650a86b614a89b69de9d4c8972d65532902688d48d37af5476f1f

Contents?: true

Size: 614 Bytes

Versions: 29

Compression:

Stored size: 614 Bytes

Contents

module Lev

  class ErrorTranslator

    def self.translate(error)
      case error.kind
      when :activerecord
        model = error.data[:model]
        attribute = error.data[:attribute]
        # TODO error.message might always be populated now -- really need the other call after ||?
        message = error.message || Lev::BetterActiveModelErrors.generate_message(model, attribute, error.code)
        Lev::BetterActiveModelErrors.full_message(model, attribute, message)
      else
        message = error.message.to_s
        message.empty? ? error.code.to_s : message
      end      
    end

  end

end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
lev-10.1.0 lib/lev/error_translator.rb
lev-10.0.0 lib/lev/error_translator.rb
lev-9.0.4 lib/lev/error_translator.rb
lev-9.0.3 lib/lev/error_translator.rb
lev-9.0.2 lib/lev/error_translator.rb
lev-9.0.1 lib/lev/error_translator.rb
lev-9.0.0 lib/lev/error_translator.rb
lev-8.1.0 lib/lev/error_translator.rb
lev-8.0.0 lib/lev/error_translator.rb
lev-7.1.0 lib/lev/error_translator.rb
lev-7.0.3 lib/lev/error_translator.rb
lev-2.2.2 lib/lev/error_translator.rb
lev-7.0.2 lib/lev/error_translator.rb
lev-7.0.1 lib/lev/error_translator.rb
lev-7.0.0 lib/lev/error_translator.rb
lev-6.0.0 lib/lev/error_translator.rb
lev-5.0.0 lib/lev/error_translator.rb
lev-4.3.2 lib/lev/error_translator.rb
lev-4.3.1 lib/lev/error_translator.rb
lev-4.3.0 lib/lev/error_translator.rb