Module: ActiveInteractor::Interactor::ClassMethods

Defined in:
lib/active_interactor/interactor.rb

Overview

Since:

  • 0.0.1

Instance Method Summary collapse

Instance Method Details

#perform(context = {}) ⇒ ActiveInteractor::Context::Base

Invoke an interactor. This is the primary public API method to an

interactor.

Examples:

Run an interactor

MyInteractor.perform(name: 'Aaron')
#=> <#MyInteractor::Context name='Aaron'>

Parameters:

  • context (Hash) (defaults to: {})

    properties to assign to the interactor context

Returns:

Since:

  • 0.0.1



33
34
35
# File 'lib/active_interactor/interactor.rb', line 33

def perform(context = {})
  new(context).execute_perform
end

#perform!(context = {}) ⇒ ActiveInteractor::Context::Base

Invoke an Interactor. The #perform! method behaves identically to

the {.perform} method with one notable exception. If the context is failed
during invocation of the interactor, the {ActiveInteractor::Context::Failure}
is raised.

Examples:

Run an interactor

MyInteractor.perform!(name: 'Aaron')
#=> <#MyInteractor::Context name='Aaron'>

Parameters:

  • context (Hash) (defaults to: {})

    properties to assign to the interactor context

Returns:

Since:

  • 0.0.1



48
49
50
# File 'lib/active_interactor/interactor.rb', line 48

def perform!(context = {})
  new(context).execute_perform!
end