Sha256: 93c36fc8aac48b6a59d4da9ca73b5236581a008c0489ef3774bf0fb663925d4c

Contents?: true

Size: 1.04 KB

Versions: 5

Compression:

Stored size: 1.04 KB

Contents

module CanTango
  module Permits
    class RoleGroupPermit < CanTango::Permit

      class Builder < CanTango::PermitEngine::Builder::Base
        #class NoAvailableRoleGroups < StandardError; end

        # builds a list of Permits for each role group of the current ability user (or account)
        # @return [Array<RoleGroupPermit::Base>] the role group permits built for this ability
        def build
          # raise NoAvailableRoleGroups, "no available roles groups are defined" if available_role_groups.empty?
          role_groups.inject([]) do |permits, role_group|
            (permits << create_permit(role_group)) if valid?(role_group)
            permits
          end.compact
        end

        def valid? role_group
          return true if !role_groups_filter?
          filter(role_group).valid?
        end

        def filter role_group
          CanTango::Filters::RoleGroupFilter.new role_group
        end

        private

        def role_groups_filter?
          CanTango.config.role_groups.filter?
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cantango-0.8.7 lib/cantango/permits/role_group_permit/builder.rb
cantango-0.8.6.2 lib/cantango/permits/role_group_permit/builder.rb
cantango-0.8.6.1 lib/cantango/permits/role_group_permit/builder.rb
cantango-0.8.6 lib/cantango/permits/role_group_permit/builder.rb
cantango-0.8.5.1 lib/cantango/permits/role_group_permit/builder.rb