2016-04-15 21:56:10 +00:00
|
|
|
class Transaction
|
2016-09-06 05:51:12 +00:00
|
|
|
def self.execute(options = {})
|
|
|
|
if options[:reset_user_id] == true
|
|
|
|
UserInfo.current_user_id = 1
|
|
|
|
end
|
|
|
|
original_interface_handle = ApplicationHandleInfo.current
|
|
|
|
if options[:interface_handle]
|
|
|
|
ApplicationHandleInfo.current = options[:interface_handle]
|
|
|
|
end
|
|
|
|
ActiveRecord::Base.transaction do
|
2017-08-13 09:54:57 +00:00
|
|
|
PushMessages.init
|
|
|
|
yield
|
|
|
|
if options[:interface_handle]
|
|
|
|
ApplicationHandleInfo.current = original_interface_handle
|
2016-09-06 05:51:12 +00:00
|
|
|
end
|
2018-05-29 15:42:14 +00:00
|
|
|
Observer::Transaction.commit(options)
|
2017-08-13 09:54:57 +00:00
|
|
|
PushMessages.finish
|
2016-09-06 05:51:12 +00:00
|
|
|
end
|
|
|
|
end
|
2016-04-15 21:56:10 +00:00
|
|
|
end
|