Sha256: 46dbafa603e6ceceeabb14a0e441ebd5c01f70ac01fa71966985c8f5a16d48b9
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
Contents
module Model module Ecm module Rbac module UserConcern extend ActiveSupport::Concern included do # associations has_many :user_roles, class_name: 'Ecm::Rbac::UserRole', inverse_of: :user has_many :roles, class_name: 'Ecm::Rbac::Role', through: :user_roles has_many :role_permissions, class_name: 'Ecm::Rbac::RolePermission', through: :roles has_many :permissions, through: :role_permissions, class_name: 'Ecm::Rbac::Permission' has_many :enabled_roles, -> { enabled }, class_name: 'Ecm::Rbac::Role', through: :user_roles # , source: :user has_many :enabled_role_permissions, class_name: 'Ecm::Rbac::RolePermission', through: :enabled_roles, source: :user_roles has_many :enabled_permissions, through: :enabled_role_permissions, class_name: 'Ecm::Rbac::Permission', source: :permission end def allowed_to?(permission_name) enabled_permissions.map(&:identifier).map(&:to_sym).include?(permission_name.to_sym) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ecm_rbac-0.0.3 | app/models/concerns/model/ecm/rbac/user_concern.rb |
ecm_rbac-0.0.2 | app/models/concerns/model/ecm/rbac/user_concern.rb |