mirror of
https://github.com/zammad/zammad
synced 2026-05-24 09:48:36 +00:00
29 lines
695 B
Ruby
29 lines
695 B
Ruby
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
require 'history'
|
|
|
|
class Observer::Session < ActiveRecord::Observer
|
|
observe 'active_record::_session_store::_session'
|
|
|
|
def before_create(record)
|
|
check(record)
|
|
end
|
|
|
|
def before_update(record)
|
|
check(record)
|
|
end
|
|
|
|
# move the persistent attribute from the sub structure
|
|
# to the first level so it gets stored in the database
|
|
# column to make the cleanup lookup more performant
|
|
def check(record)
|
|
return if !record.data
|
|
return if record[:persistent]
|
|
|
|
return if !record.data['persistent']
|
|
|
|
record[:persistent] = record.data['persistent']
|
|
record.data.delete('persistent')
|
|
end
|
|
|
|
end
|