module RightOn::RoleModel

Public Class Methods

included(base) click to toggle source
# File lib/right_on/role_model.rb, line 3
def self.included(base)
  base.module_eval do
    has_and_belongs_to_many :roles, class_name: 'RightOn::Role'
    has_many :rights, through: :roles, class_name: 'RightOn::Right'
  end
  Role.module_eval do
    has_and_belongs_to_many base.table_name.to_sym, dependent: :restrict
  end
end

Public Instance Methods

has_privileges_of?(other_user) click to toggle source
# File lib/right_on/role_model.rb, line 13
def has_privileges_of?(other_user)
  (other_user.rights - rights).empty?
end