Module: ActiveInteraction::Runnable Abstract

Extended by:
ActiveSupport::Concern
Includes:
ActiveModel::Validations
Included in:
Base
Defined in:
lib/active_interaction/concerns/runnable.rb

Overview

This module is abstract.

Include and override #execute to implement a custom Runnable class.

Note:

Must be included after ‘ActiveModel::Validations`.

Runs code and provides the result.

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#errorsErrors

Returns:



21
22
23
# File 'lib/active_interaction/concerns/runnable.rb', line 21

def errors
  @_interaction_errors
end

#executeObject

This method is abstract.

Raises:

  • (NotImplementedError)


28
29
30
# File 'lib/active_interaction/concerns/runnable.rb', line 28

def execute
  raise NotImplementedError
end

#resultObject?

Returns:

  • (Object)

    If there are no validation errors.

  • (nil)

    If there are validation errors.



34
35
36
# File 'lib/active_interaction/concerns/runnable.rb', line 34

def result
  @_interaction_result
end

#result=(result) ⇒ Object?

Parameters:

  • result (Object)

Returns:

  • (Object)

    If there are no validation errors.

  • (nil)

    If there are validation errors.



41
42
43
44
# File 'lib/active_interaction/concerns/runnable.rb', line 41

def result=(result)
  @_interaction_result = result
  @_interaction_valid = errors.empty?
end

#valid?Boolean

Returns:

  • (Boolean)


47
48
49
50
51
# File 'lib/active_interaction/concerns/runnable.rb', line 47

def valid?(*)
  return @_interaction_valid if instance_variable_defined?(:@_interaction_valid)

  super
end