Class: AmazingActivist::Failure
- Inherits:
-
Literal::Data
- Object
- Literal::Data
- AmazingActivist::Failure
show all
- Includes:
- Outcome
- Defined in:
- lib/amazing_activist/failure.rb
Constant Summary
Constants included
from Outcome
Outcome::Failure, Outcome::Success
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Outcome
#inspect, #unwrap!, #value_or
Instance Attribute Details
#context ⇒ Hash
21
|
# File 'lib/amazing_activist/failure.rb', line 21
prop :context, _Hash(_Void, _Void), &:to_h
|
#exception ⇒ Exception?
17
|
# File 'lib/amazing_activist/failure.rb', line 17
prop :exception, _Nilable(Exception)
|
#failure ⇒ Object
9
|
# File 'lib/amazing_activist/failure.rb', line 9
prop :code, _Interface(:to_sym), :positional, &:to_sym
|
Instance Method Details
#deconstruct ⇒ Array
30
31
32
|
# File 'lib/amazing_activist/failure.rb', line 30
def deconstruct
[:failure, code, activity]
end
|
#deconstruct_keys(keys) ⇒ Hash
36
37
38
39
40
41
42
|
# File 'lib/amazing_activist/failure.rb', line 36
def deconstruct_keys(keys)
if keys.nil? || keys.include?(:message)
{ failure: code, activity:, exception:, context:, message: }
else
{ failure: code, activity:, exception:, context: }
end
end
|
#failure? ⇒ Boolean
25
|
# File 'lib/amazing_activist/failure.rb', line 25
def failure? = true
|
#message ⇒ String
47
48
49
|
# File 'lib/amazing_activist/failure.rb', line 47
def message
@message || Polyglot.new(activity).message(code, **context)
end
|
#success? ⇒ Boolean
26
|
# File 'lib/amazing_activist/failure.rb', line 26
def success? = false
|