class ActiveInteractor::Organizer::InteractorInterfaceCollection

A collection of {InteractorInterface}

@api private @author Aaron Allen <hello@aaronmallen.me> @since 1.0.0

@!attribute [r] collection

An array of {InteractorInterface}

@return [Array<InteractorInterface>] the {InteractorInterface} collection

Attributes

collection[R]

Public Class Methods

new() click to toggle source

Initialize a new instance of {InteractorInterfaceCollection} @return [InteractorInterfaceCollection] a new instance of {InteractorInterfaceCollection}

# File lib/active_interactor/organizer/interactor_interface_collection.rb, line 25
def initialize
  @collection = []
end

Public Instance Methods

add(interactor_class, filters = {}) click to toggle source

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

# 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) click to toggle source

Add multiple {InteractorInterface} to the {#collection}

@param interactor_classes [Array<Const, Symbol, String>] the {ActiveInteractor::Base interactor} classes @return [self] the {InteractorInterfaceCollection} instance

# 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) click to toggle source

Calls the given block once for each element in {#collection}, passing that element as a parameter. @return [self] the {InteractorInterfaceCollection} instance

# File lib/active_interactor/organizer/interactor_interface_collection.rb, line 56
def each(&block)
  collection.each(&block) if block
  self
end