Class: Error

Inherits:
Object
  • Object
show all
Defined in:
app/services/error.rb

Overview

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(errors = nil) ⇒ Error

Pass 1 string or array of strings



5
6
7
8
# File 'app/services/error.rb', line 5

def initialize(errors = nil)
  errors = [] unless errors
  @errors = [errors].flatten # handle array or string
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



3
4
5
# File 'app/services/error.rb', line 3

def errors
  @errors
end

Instance Method Details

#displayObject



18
19
20
21
22
23
# File 'app/services/error.rb', line 18

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

#error_messageObject



10
11
12
# File 'app/services/error.rb', line 10

def error_message
  error[0]
end

#success?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'app/services/error.rb', line 14

def success?
  false
end