Sha256: 6041f99a92fa55f66e6af1845fc316af905c16bdf1d80b69f1d8c43fc9549700

Contents?: true

Size: 349 Bytes

Versions: 2

Compression:

Stored size: 349 Bytes

Contents

class Error
  attr_reader :errors
  # Pass 1 string or array of strings
  def initialize(errors = nil)
    errors = [] unless errors
    @errors = [errors].flatten # handle array or string
  end

  def error_message
    errors[0]
  end

  def success?
    false
  end

  def display
    {
      success: false,
      errors: @errors
    }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
at_your_service-1.1.0 lib/at_your_service/error.rb
at_your_service-1.0.0 lib/at_your_service/error.rb