trabajo-afectivo/lib/sessions/backend/base.rb

25 lines
678 B
Ruby
Raw Normal View History

2016-03-03 08:56:13 +00:00
class Sessions::Backend::Base
2016-03-03 08:56:13 +00:00
def initialize(user, asset_lookup, client, client_id, ttl = 30)
@user = user
@client = client
@client_id = client_id
@ttl = ttl
@asset_lookup = asset_lookup
@last_change = nil
end
def asset_needed?(record)
class_name = record.class.to_s
if !@asset_lookup || !@asset_lookup[class_name] || !@asset_lookup[class_name][record.id] || @asset_lookup[class_name][record.id] < record.updated_at
if !@asset_lookup[class_name]
@asset_lookup[class_name] = {}
end
@asset_lookup[class_name][record.id] = record.updated_at
return true
end
false
end
end