module Interactor::ClassMethods
Internal: Interactor
class methods.
Public Instance Methods
call(context = {})
click to toggle source
Public: Invoke an Interactor
. This is the primary public API method to an interactor.
context - A Hash whose key/value pairs are used in initializing a new
Interactor::Context object. An existing Interactor::Context may also be given. (default: {})
Examples
MyInteractor.call(foo: "bar") # => #<Interactor::Context foo="bar"> MyInteractor.call # => #<Interactor::Context>
Returns the resulting Interactor::Context
after manipulation by the
interactor.
# File lib/interactor.rb, line 49 def call(context = {}) new(context).tap(&:run).context end
call!(context = {})
click to toggle source
Public: Invoke an Interactor
. The “call!” method behaves identically to the “call” method with one notable exception. If the context is failed during invocation of the interactor, the Interactor::Failure
is raised.
context - A Hash whose key/value pairs are used in initializing a new
Interactor::Context object. An existing Interactor::Context may also be given. (default: {})
Examples
MyInteractor.call!(foo: "bar") # => #<Interactor::Context foo="bar"> MyInteractor.call! # => #<Interactor::Context> MyInteractor.call!(foo: "baz") # => Interactor::Failure: #<Interactor::Context foo="baz">
Returns the resulting Interactor::Context
after manipulation by the
interactor.
Raises Interactor::Failure
if the context is failed.
# File lib/interactor.rb, line 75 def call!(context = {}) new(context).tap(&:run!).context end