Module: Granite::Action::Performing::ClassMethods

Defined in:
lib/granite/action/performing.rb

Instance Method Summary collapse

Instance Method Details

#handle_exception(klass, &block) ⇒ Hash<Class, Proc>

Register default handler for exceptions thrown inside execute_perform! method.

Parameters:

  • klass

    Exception class, could be parent class too [Class]

  • block (Block<Exception>)

    with default behavior for handling specified type exceptions. First block argument is raised exception instance.

Returns:

  • (Hash<Class, Proc>)

    Registered handlers



38
39
40
# File 'lib/granite/action/performing.rb', line 38

def handle_exception(klass, &block)
  self._exception_handlers = _exception_handlers.merge(klass => block)
end

#performObject



42
43
44
# File 'lib/granite/action/performing.rb', line 42

def perform(*)
  fail 'Perform block declaration was removed! Please declare `private def execute_perform!(*)` method'
end