Sha256: 82694d9141c0d346940a5d6b0aaa0b848852a59f15f5179124b756e35ca181f1
Contents?: true
Size: 1.38 KB
Versions: 1
Compression:
Stored size: 1.38 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, dependent: :destroy 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 def roles_count roles.count end def enabled_roles_count enabled_roles.count end def permissions_count permissions.count end def enabled_permissions_count enabled_permissions.count end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ecm_rbac-0.0.4 | app/models/concerns/model/ecm/rbac/user_concern.rb |