14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/rollbacker/base.rb', line 14
def rollbacker(*args, &blk)
unless self.included_modules.include?(ActiveRecord::Transactions::ClassMethods)
include ActiveRecord::Transactions::ClassMethods
end
unless self.included_modules.include?(Rollbacker::Base::InstanceMethods)
include InstanceMethods
include Rollbacker::Status unless self.included_modules.include?(Rollbacker::Status)
has_many :rollbacker_changes, :as => :rollbackable
end
config = Rollbacker::Config.new(*args)
config.actions.each do |action|
send "before_#{action}", Rollbacker::DatabaseRollback.new(config.options)
end
send :after_rollback, Rollbacker::Recorder.new(config.options, &blk)
end
|