transaction.rb 576 B

1234567891011121314151617181920
  1. class Transaction
  2. def self.execute(options = {})
  3. if options[:reset_user_id] == true
  4. UserInfo.current_user_id = 1
  5. end
  6. original_interface_handle = ApplicationHandleInfo.current
  7. if options[:interface_handle]
  8. ApplicationHandleInfo.current = options[:interface_handle]
  9. end
  10. ActiveRecord::Base.transaction do
  11. PushMessages.init
  12. yield
  13. if options[:interface_handle]
  14. ApplicationHandleInfo.current = original_interface_handle
  15. end
  16. Observer::Transaction.commit(options)
  17. PushMessages.finish
  18. end
  19. end
  20. end