Module: Errgonomic
- Defined in:
- lib/errgonomic.rb,
lib/errgonomic/option.rb,
lib/errgonomic/result.rb,
lib/errgonomic/version.rb
Overview
Errgonomic adds opinionated abstractions to handle errors in a way that blends Rust and Ruby ergonomics. This library leans on Rails conventions for some presence-related methods; when in doubt, make those feel like Rails. It also has an implementation of Option and Result; when in doubt, make those feel more like Rust.
Defined Under Namespace
Modules: Option, Result Classes: ArgumentError, Error, ExpectError, NotComparableError, NotPresentError, ResultRequiredError, TypeMismatchError, UnwrapError
Constant Summary collapse
- VERSION =
"0.3.0"
Class Method Summary collapse
-
.give_me_ambiguous_downstream_errors? ⇒ Boolean
A little bit of control over how pedantic we are in our runtime type checks.
- .give_me_lenient_inner_value_comparison=(value) ⇒ Object
-
.lenient_inner_value_comparison? ⇒ Boolean
Lenient inner value comparison means the inner value of a Some or Ok can be compared to some other non-Result or non-Option value.
-
.with_ambiguous_downstream_errors ⇒ Object
You can opt out of the pedantic runtime checks for lazy block evaluation, but not quietly.
Class Method Details
.give_me_ambiguous_downstream_errors? ⇒ Boolean
A little bit of control over how pedantic we are in our runtime type checks.
38 39 40 |
# File 'lib/errgonomic.rb', line 38 def self.give_me_ambiguous_downstream_errors? @give_me_ambiguous_downstream_errors || true end |
.give_me_lenient_inner_value_comparison=(value) ⇒ Object
58 59 60 |
# File 'lib/errgonomic.rb', line 58 def self.give_me_lenient_inner_value_comparison=(value) @lenient_inner_value_comparison = value end |
.lenient_inner_value_comparison? ⇒ Boolean
Lenient inner value comparison means the inner value of a Some or Ok can be compared to some other non-Result or non-Option value.
54 55 56 |
# File 'lib/errgonomic.rb', line 54 def self.lenient_inner_value_comparison? @lenient_inner_value_comparison ||= true end |
.with_ambiguous_downstream_errors ⇒ Object
You can opt out of the pedantic runtime checks for lazy block evaluation, but not quietly.
44 45 46 47 48 49 50 |
# File 'lib/errgonomic.rb', line 44 def self.with_ambiguous_downstream_errors original_value = @give_me_ambiguous_downstream_errors @give_me_ambiguous_downstream_errors = true yield ensure @give_me_ambiguous_downstream_errors = original_value end |