Module: Antrapol::ToolRack::ExceptionUtils
- Includes:
- ConditionUtils
- Defined in:
- lib/toolrack/exception_utils.rb
Instance Method Summary collapse
-
#raise_if_empty(val, message, error = StandardError) ⇒ Object
(also: #raise_if_empty?)
raise_if_empty Raise the given (or default if not given) exception if the val given is empty val - variable/object that shall be tested for emptiness message - message to be thrown if it is true error - exception object to be thrown.
-
#raise_if_false(bool, message, error = StandardError) ⇒ Object
(also: #raise_if_false?)
raise_if_false.
-
#raise_if_true(bool, message, error = StandardError) ⇒ Object
(also: #raise_if_true?)
raise_if_true.
Instance Method Details
#raise_if_empty(val, message, error = StandardError) ⇒ Object Also known as: raise_if_empty?
raise_if_empty Raise the given (or default if not given) exception if the val given is empty val - variable/object that shall be tested for emptiness message - message to be thrown if it is true error - exception object to be thrown
14 15 16 |
# File 'lib/toolrack/exception_utils.rb', line 14 def raise_if_empty(val, , error = StandardError) raise_error(,error) if is_empty?(val) end |
#raise_if_false(bool, message, error = StandardError) ⇒ Object Also known as: raise_if_false?
raise_if_false
22 23 24 25 26 |
# File 'lib/toolrack/exception_utils.rb', line 22 def raise_if_false(bool, , error = StandardError) if not bool raise_error(,error) end end |
#raise_if_true(bool, message, error = StandardError) ⇒ Object Also known as: raise_if_true?
raise_if_true
32 33 34 |
# File 'lib/toolrack/exception_utils.rb', line 32 def raise_if_true(bool, , error = StandardError) raise_if_false(!bool, , error) end |