Class: Perfume::Exit

Inherits:
Service show all
Defined in:
lib/perfume/exit.rb

Overview

Public: There’s often need to exit from the app in a testable and graceful manner. Simple call to Kernel#exit isn’t such. This simple wrapper around the Kernel method allows to say goodbye message via service logging as well as status code.

Instance Method Summary collapse

Methods inherited from Service

call

Methods included from Gallus::Logging

included

Methods inherited from SuperObject

args, args_accessor, args_reader, args_writer, #init, init_args, #initialize

Constructor Details

This class inherits a constructor from Perfume::SuperObject

Instance Method Details

#callObject



18
19
20
21
# File 'lib/perfume/exit.rb', line 18

def call
  log.error(@message)
  Kernel.exit(@code)
end

#defaultsObject



10
11
12
# File 'lib/perfume/exit.rb', line 10

def defaults
  { message: "Exiting...", code: 1 }
end

#logObject



14
15
16
# File 'lib/perfume/exit.rb', line 14

def log
  @log ||= self.class.log
end