Sha256: 0ccf05d96447e33877b89820c16122c9e30169675ea480f8dacff6b64635319b
Contents?: true
Size: 839 Bytes
Versions: 51
Compression:
Stored size: 839 Bytes
Contents
module Fiona7 class PermissionVolatileCache PERMISSION_KEY = "F7PERMISSION_CACHE" def initialize(request) request[PERMISSION_KEY] ||= {} self.storage = request[PERMISSION_KEY] end def permitted?(user_name, obj_id, action) self.storage["#{user_name}:#{obj_id}:#{action}"] ||= lookup(user_name, obj_id, action) end protected attr_accessor :storage def lookup(user_name, obj_id, action) return false unless user_name && obj_id && action obj = Fiona7::EditedObj.new obj.obj_id = obj_id.to_i return obj.permission.send(:"#{action}?", user_name) rescue Reactor::Cm::XmlSingleRequestError => e Rails.logger.error("Error looking up the permission of #{user_name} for obj #{obj_id} for action #{action}:\n#{e.message}") return false end end end
Version data entries
51 entries across 51 versions & 1 rubygems