Class: Lcms::Engine::BaseInteractor

Inherits:
Object
  • Object
show all
Defined in:
app/interactors/lcms/engine/base_interactor.rb

Overview

Base interactor to be used on the controllers Usage:

class MyController
  def my_action
    interactor = MyInteractor.call(self)
    if interactor.success?
        # do something
    else
        # use interactor.error
    end

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ BaseInteractor

Returns a new instance of BaseInteractor.



25
26
27
# File 'app/interactors/lcms/engine/base_interactor.rb', line 25

def initialize(context)
  @context = context
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



23
24
25
# File 'app/interactors/lcms/engine/base_interactor.rb', line 23

def error
  @error
end

Class Method Details

.call(context) ⇒ Object



17
18
19
20
21
# File 'app/interactors/lcms/engine/base_interactor.rb', line 17

def self.call(context)
  interactor = new(context)
  interactor.run
  interactor
end

Instance Method Details

#runObject

Raises:

  • (NotImplementedError)


33
34
35
# File 'app/interactors/lcms/engine/base_interactor.rb', line 33

def run
  raise NotImplementedError
end

#success?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'app/interactors/lcms/engine/base_interactor.rb', line 29

def success?
  @error.nil?
end