module Scrivito class Session def self.renew(id, user) payload = { session: { role: 'editor', user_id: user.id, permissions: permissions(user), }, } CmsRestApi.task_unaware_request(:put, "sessions/#{id}", payload) end def self.permissions(user) Hash[user.explicit_rules.map do |permission, verb, _, _| [verb, permission.to_s] end] end private_class_method :permissions end end