Module: ActiveInteractor::Context::Loader Private
- Defined in:
- lib/active_interactor/context/loader.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Find or create context classes for a given interactor
Constant Summary collapse
- BASE_CLASSES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
ActiveInteractor base classes
[ActiveInteractor::Base, ActiveInteractor::Organizer::Base].freeze
- BASE_CONTEXT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
The Base class
ActiveInteractor::Context::Base
Class Method Summary collapse
-
.create(context_class_name, interactor_class) ⇒ Const
private
Create a context class for a given interactor.
-
.find_or_create(interactor_class) ⇒ Const
private
Find or create a context class for a given interactor.
Class Method Details
.create(context_class_name, interactor_class) ⇒ Const
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Create a context class for a given interactor
24 25 26 |
# File 'lib/active_interactor/context/loader.rb', line 24 def self.create(context_class_name, interactor_class) interactor_class.const_set(context_class_name.to_s.camelize, Class.new(BASE_CONTEXT)) end |
.find_or_create(interactor_class) ⇒ Const
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Find or create a context class for a given interactor. If a class exists
following the pattern of InteractorNameContext
or InteractorName::Context
then that class will be returned
otherwise a new class will be created with the pattern InteractorName::Context
.
34 35 36 37 38 39 |
# File 'lib/active_interactor/context/loader.rb', line 34 def self.find_or_create(interactor_class) return BASE_CONTEXT if BASE_CLASSES.include?(interactor_class) klass = possible_classes(interactor_class).first klass || create('Context', interactor_class) end |