session.rb 695 B

1234567891011121314151617181920212223242526272829
  1. # Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
  2. require 'history'
  3. class Observer::Session < ActiveRecord::Observer
  4. observe 'active_record::_session_store::_session'
  5. def before_create(record)
  6. check(record)
  7. end
  8. def before_update(record)
  9. check(record)
  10. end
  11. # move the persistent attribute from the sub structure
  12. # to the first level so it gets stored in the database
  13. # column to make the cleanup lookup more performant
  14. def check(record)
  15. return if !record.data
  16. return if record[:persistent]
  17. return if !record.data['persistent']
  18. record[:persistent] = record.data['persistent']
  19. record.data.delete('persistent')
  20. end
  21. end