Class: CemAcpt::ErrorActionResult

Inherits:
Object
  • Object
show all
Defined in:
lib/cem_acpt/action_result.rb

Overview

Wrapper class for an error raised during an action.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error) ⇒ ErrorActionResult

Returns a new instance of ErrorActionResult.



42
43
44
# File 'lib/cem_acpt/action_result.rb', line 42

def initialize(error)
  @error = error
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



40
41
42
# File 'lib/cem_acpt/action_result.rb', line 40

def error
  @error
end

Instance Method Details

#error?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/cem_acpt/action_result.rb', line 46

def error?
  true
end

#inspectObject



58
59
60
# File 'lib/cem_acpt/action_result.rb', line 58

def inspect
  to_s
end

#resultsObject



75
76
77
# File 'lib/cem_acpt/action_result.rb', line 75

def results
  @error.backtrace
end

#results?Boolean

Returns:

  • (Boolean)


79
80
81
# File 'lib/cem_acpt/action_result.rb', line 79

def results?
  true
end

#statusObject Also known as: http_status



70
71
72
# File 'lib/cem_acpt/action_result.rb', line 70

def status
  1
end

#success?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/cem_acpt/action_result.rb', line 50

def success?
  false
end

#summaryObject



83
84
85
# File 'lib/cem_acpt/action_result.rb', line 83

def summary
  @error.message
end

#summary?Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/cem_acpt/action_result.rb', line 87

def summary?
  true
end

#to_hObject



62
63
64
65
66
67
68
# File 'lib/cem_acpt/action_result.rb', line 62

def to_h
  {
    class: @error.class.name,
    message: @error.message,
    backtrace: @error.backtrace,
  }
end

#to_sObject



54
55
56
# File 'lib/cem_acpt/action_result.rb', line 54

def to_s
  "#<#{@error.class.name}:0x#{@error.object_id.to_s(16)}>"
end