Sha256: a15e1b28d7613825cb944669668c5d1f91c8ac1743dfbf924c79849db1f517c9

Contents?: true

Size: 516 Bytes

Versions: 1

Compression:

Stored size: 516 Bytes

Contents

# frozen_string_literal: true

module SmartError
  class ModelError < SmartError::BaseError
    def error_code
      SmartError.model_error_code
    end

    def message
      case SmartError.model_error_message
      when :first then @error.errors.full_messages.first
      when :sentence then @error.errors.full_messages.to_sentence
      when :last then @error.errors.full_messages.last
      else @error.errors.full_messages.first
      end
    end

    def details
      @error.errors.details
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
smart_error-1.0.0 lib/smart_error/model_error.rb