sets_persistent_flag.rb 647 B

1234567891011121314151617181920212223242526
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Session::SetsPersistentFlag
  3. extend ActiveSupport::Concern
  4. included do
  5. before_create :session_set_persistent_flag
  6. before_update :session_set_persistent_flag
  7. end
  8. private
  9. # move the persistent attribute from the sub structure
  10. # to the first level so it gets stored in the database
  11. # column to make the cleanup lookup more performant
  12. def session_set_persistent_flag
  13. return if !data
  14. return if self[:persistent]
  15. return if !data['persistent']
  16. self[:persistent] = data['persistent']
  17. data.delete('persistent')
  18. end
  19. end