Sha256: dc2392e9f5c4f06f9fb70db4e5bd2a30c1c1b1112f7aad51bc9a4aba1dd25252
Contents?: true
Size: 872 Bytes
Versions: 1
Compression:
Stored size: 872 Bytes
Contents
module Interactor module Organizer def self.included(base) base.class_eval do include Interactor extend ClassMethods include InstanceMethods end end module ClassMethods def interactors @interactors ||= [] end def organize(*interactors) @interactors = interactors.flatten end end module InstanceMethods def interactors self.class.interactors end def perform interactors.each do |interactor| performed << interactor interactor.perform(context) rollback && break if context.failure? end end def rollback performed.reverse_each do |interactor| interactor.rollback(context) end end def performed @performed ||= [] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
interactor-1.0.0 | lib/interactor/organizer.rb |