Sha256: 8ba6ae9e2b64aac642eae6cd8b6ff58866874713f883cf268e3b32777f4daca7
Contents?: true
Size: 1.07 KB
Versions: 1
Compression:
Stored size: 1.07 KB
Contents
module Alberich class PermissionSession < ActiveRecord::Base attr_accessible :session_id, :user_id, :user belongs_to :user, :class_name => Alberich.user_class has_many :session_entities validates_presence_of :user_id validates_presence_of :session_id def update_session_entities(user) SessionEntity.transaction do # skips callbacks, which should be fine here SessionEntity.delete_all(:permission_session_id => self.id) add_to_session(user) end end def add_to_session(user) return unless user # create mapping for user-level permissions SessionEntity.create!(:permission_session_id => self.id, :user => user, :entity => Entity.for_target(user)) # create mappings for groups user.send(Alberich.groups_for_user_method).each do |ug| SessionEntity.create!(:permission_session_id => self.id, :user => user, :entity => Entity.for_target(ug)) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
alberich-0.2.0 | app/models/alberich/permission_session.rb |