lib/zertico/organizer.rb in zertico-1.3.0 vs lib/zertico/organizer.rb in zertico-2.0.0.alpha.1

- old
+ new

@@ -1,26 +1,28 @@ module Zertico module Organizer - attr_reader :interactors_classes, :performed + attr_reader :interactors_classes, :instances, :performed def organize(interactors) - @performed = [] @interactors_classes = Array(interactors) + @performed = [] + @instances = {} end def perform(params) - @params = params interactors_classes.each do |interactor_class| interactor = interactor_class.new - interactor.perform(@params) + 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.map(&:rollback) + performed.reverse.map(&:rollback) end end end \ No newline at end of file