Sha256: 3f1bdc5eceb148e967bb3200245e95b162b85a79ed3c6f89c234947c4a18bb45
Contents?: true
Size: 701 Bytes
Versions: 6
Compression:
Stored size: 701 Bytes
Contents
module ActsPermissive class Permission < ActiveRecord::Base has_many :groupings, :dependent => :destroy belongs_to :circle validates_presence_of :circle, :mask set_table_name :permissive_permissions scope :in, lambda { |circle| where("circle_id = #{circle.id}") } scope :for, lambda { |user| joins(:groupings).where("permissive_groupings.permissible_id = #{user.id} AND permissive_groupings.permissible_type = '#{user.class.to_s}'").readonly(false) } class << self def bit_for permission PermissionMap.hash[permission.to_s.downcase.to_sym] || 0 end end def reset! self.mask = 0 save! end end end
Version data entries
6 entries across 6 versions & 1 rubygems