Module: Errgonomic
- Defined in:
- lib/errgonomic.rb,
lib/errgonomic/rails.rb,
lib/errgonomic/option.rb,
lib/errgonomic/result.rb,
lib/errgonomic/version.rb,
lib/errgonomic/rails/active_record_optional.rb,
lib/errgonomic/rails/active_record_optional.rb,
lib/errgonomic/rails/active_record_delegate_optional.rb,
lib/errgonomic/rails/active_record_optional.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, Rails, Result Classes: ArgumentError, Error, ExpectError, NotComparableError, NotPresentError, Railtie, ResultRequiredError, SerializeError, TypeError, TypeMismatchError, UnwrapError
Constant Summary collapse
- VERSION =
'0.7.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. Default is false: we are pedantic and raise errors on type mismatches.
53 54 55 |
# File 'lib/errgonomic.rb', line 53 def self.give_me_ambiguous_downstream_errors? !!@give_me_ambiguous_downstream_errors end |
.give_me_lenient_inner_value_comparison=(value) ⇒ Object
73 74 75 |
# File 'lib/errgonomic.rb', line 73 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.
69 70 71 |
# File 'lib/errgonomic.rb', line 69 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.
59 60 61 62 63 64 65 |
# File 'lib/errgonomic.rb', line 59 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 |