Class: ActiveInteractor::Organizer::InteractorInterfaceCollection Private
- Inherits:
-
Object
- Object
- ActiveInteractor::Organizer::InteractorInterfaceCollection
- Defined in:
- lib/active_interactor/organizer/interactor_interface_collection.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A collection of InteractorInterface
Instance Attribute Summary collapse
-
#collection ⇒ Array<InteractorInterface>
readonly
private
An array of InteractorInterface.
Instance Method Summary collapse
-
#add(interactor_class, filters = {}) ⇒ self
private
Add an InteractorInterface to the #collection.
-
#concat(interactor_classes) ⇒ self
private
Add multiple InteractorInterface to the #collection.
-
#each(&block) ⇒ self
private
Calls the given block once for each element in #collection, passing that element as a parameter.
-
#initialize ⇒ InteractorInterfaceCollection
constructor
private
Initialize a new instance of InteractorInterfaceCollection.
-
#map(&block) ⇒ Array
Invokes the given block once for each element of #collection.
Constructor Details
#initialize ⇒ InteractorInterfaceCollection
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.
Initialize a new instance of ActiveInteractor::Organizer::InteractorInterfaceCollection
25 26 27 |
# File 'lib/active_interactor/organizer/interactor_interface_collection.rb', line 25 def initialize @collection = [] end |
Instance Attribute Details
#collection ⇒ Array<InteractorInterface> (readonly)
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.
An array of ActiveInteractor::Organizer::InteractorInterface
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/active_interactor/organizer/interactor_interface_collection.rb', line 15 class InteractorInterfaceCollection attr_reader :collection # @!method map(&block) # Invokes the given block once for each element of {#collection}. # @return [Array] a new array containing the values returned by the block. delegate :map, to: :collection # Initialize a new instance of {InteractorInterfaceCollection} # @return [InteractorInterfaceCollection] a new instance of {InteractorInterfaceCollection} def initialize @collection = [] end # Add an {InteractorInterface} to the {#collection} # # @param interactor_class [Const, Symbol, String] an {ActiveInteractor::Base interactor} class # @param filters [Hash{Symbol=> Proc, Symbol}] conditional options for the {ActiveInteractor::Base interactor} # class # @option filters [Proc, Symbol] :if only call the {ActiveInteractor::Base interactor} # {Interactor::Perform::ClassMethods#perform .perform} if `Proc` or `method` returns `true` # @option filters [Proc, Symbol] :unless only call the {ActiveInteractor::Base interactor} # {Interactor::Perform::ClassMethods#perform .perform} if `Proc` or `method` returns `false` or `nil` # @return [self] the {InteractorInterfaceCollection} instance def add(interactor_class, filters = {}) interface = ActiveInteractor::Organizer::InteractorInterface.new(interactor_class, filters) collection << interface if interface.interactor_class self end # Add multiple {InteractorInterface} to the {#collection} # # @param interactor_classes [Array<Const, Symbol, String>] the {ActiveInteractor::Base interactor} classes # @return [self] the {InteractorInterfaceCollection} instance def concat(interactor_classes) interactor_classes.flatten.each { |interactor_class| add(interactor_class) } self end # Calls the given block once for each element in {#collection}, passing that element as a parameter. # @return [self] the {InteractorInterfaceCollection} instance def each(&block) collection.each(&block) if block self end end |
Instance Method Details
#add(interactor_class, filters = {}) ⇒ self
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.
Add an ActiveInteractor::Organizer::InteractorInterface to the #collection
39 40 41 42 43 |
# File 'lib/active_interactor/organizer/interactor_interface_collection.rb', line 39 def add(interactor_class, filters = {}) interface = ActiveInteractor::Organizer::InteractorInterface.new(interactor_class, filters) collection << interface if interface.interactor_class self end |
#concat(interactor_classes) ⇒ self
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.
Add multiple ActiveInteractor::Organizer::InteractorInterface to the #collection
49 50 51 52 |
# File 'lib/active_interactor/organizer/interactor_interface_collection.rb', line 49 def concat(interactor_classes) interactor_classes.flatten.each { |interactor_class| add(interactor_class) } self end |
#each(&block) ⇒ self
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.
Calls the given block once for each element in #collection, passing that element as a parameter.
56 57 58 59 |
# File 'lib/active_interactor/organizer/interactor_interface_collection.rb', line 56 def each(&block) collection.each(&block) if block self end |
#map(&block) ⇒ Array
Invokes the given block once for each element of #collection.
21 |
# File 'lib/active_interactor/organizer/interactor_interface_collection.rb', line 21 delegate :map, to: :collection |