Module: Confium::Errors::Coerce
- Defined in:
- lib/confium/errors/coerce.rb
Class Method Summary collapse
-
.args(message, details_hash, kwargs) ⇒ Object
Normalize the (message, details_hash, kwargs) triple that every typed-error initializer receives.
Class Method Details
.args(message, details_hash, kwargs) ⇒ Object
Normalize the (message, details_hash, kwargs) triple that every
typed-error initializer receives. Returns [message, kwargs]
where:
messageisnilor a String (never a Hash)kwargsis a Hash with symbol keys, containing every key from the originaldetails_hashand**kwargs, plus anything that was tucked insidemessage(when the caller passed a Hash as the first arg).
The subclass initializer then kwargs.delete(:specific_field)
to pull its own fields out, and the leftover **kwargs flows
to super as details:.
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/confium/errors/coerce.rb', line 37 def args(, details_hash, kwargs) if .is_a?(Hash) kwargs = .transform_keys(&:to_sym).merge(kwargs) = kwargs.delete(:message) end if details_hash.is_a?(Hash) kwargs = details_hash.transform_keys(&:to_sym).merge(kwargs) end [, kwargs] end |