Sha256: c0801666369f9a4fe84ae3b62c7aa58ce69db2ed1794a30bb306dbaafd0920ed

Contents?: true

Size: 699 Bytes

Versions: 5

Compression:

Stored size: 699 Bytes

Contents

module CanTango
  module Permits
    class RolePermit < CanTango::Permit
      class Builder < CanTango::PermitEngine::Builder::Base
        # builds a list of Permits for each role of the current ability user (or account)
        # @return [Array<RoleGroupPermit::Base>] the role permits built for this ability
        def build
          roles.inject([]) do |permits, role|
            (permits << create_permit(role)) if valid?(role.to_sym)
            permits
          end.compact
        end

        protected

        def valid? role
          filter(role).valid?
        end

        def filter role
          CanTango::Filters::RoleFilter.new role
        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_permit/builder.rb
cantango-0.8.6.2 lib/cantango/permits/role_permit/builder.rb
cantango-0.8.6.1 lib/cantango/permits/role_permit/builder.rb
cantango-0.8.6 lib/cantango/permits/role_permit/builder.rb
cantango-0.8.5.1 lib/cantango/permits/role_permit/builder.rb