Class: Lcms::Engine::BaseInteractor
- Inherits:
-
Object
- Object
- Lcms::Engine::BaseInteractor
- 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
Direct Known Subclasses
EnhanceInstructionInteractor, ExploreCurriculumInteractor, FindLessonsInteractor, SearchInteractor
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(context) ⇒ BaseInteractor
constructor
A new instance of BaseInteractor.
- #run ⇒ Object
- #success? ⇒ Boolean
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
#error ⇒ Object (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
#run ⇒ Object
33 34 35 |
# File 'app/interactors/lcms/engine/base_interactor.rb', line 33 def run raise NotImplementedError end |
#success? ⇒ Boolean
29 30 31 |
# File 'app/interactors/lcms/engine/base_interactor.rb', line 29 def success? @error.nil? end |