Sha256: 2e74897a22e6845369692d266e8e2e55b3282c56b2f03ccebbdf07e67a816d02

Contents?: true

Size: 680 Bytes

Versions: 4

Compression:

Stored size: 680 Bytes

Contents

module Zertico
  module Organizer
    attr_reader :interactors_classes, :instances, :performed

    def organize(interactors)
      @interactors_classes = Array(interactors)
      @performed = []
      @instances = {}
    end

    def perform(params)
      interactors_classes.each do |interactor_class|
        interactor = interactor_class.new
        interactor.inject_instances(instances)
        interactor.perform(params)
        instances.merge!(interactor.get_instances)
        performed << interactor
      end
      true
    rescue Zertico::Exceptions::RollbackException
      rollback
    end

    def rollback
      performed.reverse.map(&:rollback)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
zertico-2.0.0.beta.1 lib/zertico/organizer.rb
zertico-2.0.0.alpha.3 lib/zertico/organizer.rb
zertico-2.0.0.alpha.2 lib/zertico/organizer.rb
zertico-2.0.0.alpha.1 lib/zertico/organizer.rb