Class: CanTango::Builder::Permit::RoleGroup
- Inherits:
-
Base
- Object
- Base
- CanTango::Builder::Permit::RoleGroup
- Includes:
- Helpers::Debug
- Defined in:
- lib/cantango/roles_ext/builder/permit/role_group.rb
Instance Method Summary collapse
-
#build ⇒ Array<RoleGroupPermit::Base>
builds a list of Permits for each role group of the current ability user (or account).
- #filter(role_group) ⇒ Object
- #name ⇒ Object
- #valid?(role_group) ⇒ Boolean
Instance Method Details
#build ⇒ Array<RoleGroupPermit::Base>
builds a list of Permits for each role group of the current ability user (or account)
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/cantango/roles_ext/builder/permit/role_group.rb', line 7 def build matching_permits = matching_role_groups(roles).inject([]) do |permits, role_group| debug "Building RoleGroupPermit for #{role_group}" (permits << create_permit(role_group)) if valid?(role_group) permits end.compact if matching_permits.empty? debug "Not building any RoleGroupPermits since no role groups could be found that are relevant for the permission candidate" return [] end matching_permits end |
#filter(role_group) ⇒ Object
30 31 32 |
# File 'lib/cantango/roles_ext/builder/permit/role_group.rb', line 30 def filter role_group CanTango::Filters::RoleGroupFilter.new role_group end |
#name ⇒ Object
21 22 23 |
# File 'lib/cantango/roles_ext/builder/permit/role_group.rb', line 21 def name :role_group end |
#valid?(role_group) ⇒ Boolean
25 26 27 28 |
# File 'lib/cantango/roles_ext/builder/permit/role_group.rb', line 25 def valid? role_group return true if !role_groups_filter? filter(role_group).valid? end |