Module: Interaktor::Organizer::InstanceMethods

Defined in:
lib/interaktor/organizer.rb

Instance Method Summary collapse

Instance Method Details

#callvoid

This method returns an undefined value.

Invoke the organized Interaktors. An Interaktor::Organizer is expected NOT to define its own #call in favor of this default implementation.



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/interaktor/organizer.rb', line 41

def call
  self.class.organized.each do |interaktor|
    # Take the context that is being passed to each interaktor and remove
    # any attributes from it that are not required by the interactor.
    @context.to_h
            .keys
            .reject { |attr| interaktor.input_attributes.include?(attr) }
            .each { |attr| @context.delete_field(attr) }

    catch(:early_return) { interaktor.call!(@context) }
  end
end