Module: MotherBrain::Mixin::CodedExit::ClassMethods
- Defined in:
- lib/mb/mixin/coded_exit.rb
Instance Method Summary collapse
-
#exit_code_for(const_name) ⇒ Integer
(also: #exit_status_for)
Look up the exit status for motherbrain error matching the given name.
-
#exit_with(obj) ⇒ Object
Exit the application with the exit status associated with the given motherbrain error.
Instance Method Details
#exit_code_for(const_name) ⇒ Integer Also known as: exit_status_for
Look up the exit status for motherbrain error matching the given name
42 43 44 |
# File 'lib/mb/mixin/coded_exit.rb', line 42 def exit_code_for(const_name) MB.const_get(const_name).exit_code end |
#exit_with(obj) ⇒ Object
Exit the application with the exit status associated with the given motherbrain error
26 27 28 29 30 31 |
# File 'lib/mb/mixin/coded_exit.rb', line 26 def exit_with(obj) err_const = obj.is_a?(String) ? constant_for(obj) : obj exit_code = err_const.try(:exit_code) || MBError::DEFAULT_EXIT_CODE Kernel.exit(exit_code) end |