base.rb 678 B

123456789101112131415161718192021222324
  1. class Sessions::Backend::Base
  2. def initialize(user, asset_lookup, client, client_id, ttl = 30)
  3. @user = user
  4. @client = client
  5. @client_id = client_id
  6. @ttl = ttl
  7. @asset_lookup = asset_lookup
  8. @last_change = nil
  9. end
  10. def asset_needed?(record)
  11. class_name = record.class.to_s
  12. if !@asset_lookup || !@asset_lookup[class_name] || !@asset_lookup[class_name][record.id] || @asset_lookup[class_name][record.id] < record.updated_at
  13. if !@asset_lookup[class_name]
  14. @asset_lookup[class_name] = {}
  15. end
  16. @asset_lookup[class_name][record.id] = record.updated_at
  17. return true
  18. end
  19. false
  20. end
  21. end