Sha256: fb3bc569d136b3e81ba912bb005abb119e99bdbee3015e6866b2fc1af559a8c7

Contents?: true

Size: 913 Bytes

Versions: 9

Compression:

Stored size: 913 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
          if roles.empty?
            puts "Not building any RolePermit" if CanTango.debug?
            return [] if roles.empty?
          end
          roles.inject([]) do |permits, role|
            puts "Building RolePermit for #{role}" if CanTango.debug?
            (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

9 entries across 9 versions & 1 rubygems

Version Path
cantango-0.9.3.2 lib/cantango/permits/role_permit/builder.rb
cantango-0.8.9.5 lib/cantango/permits/role_permit/builder.rb
cantango-0.8.9.4 lib/cantango/permits/role_permit/builder.rb
cantango-0.8.9.3 lib/cantango/permits/role_permit/builder.rb
cantango-0.8.9.2 lib/cantango/permits/role_permit/builder.rb
cantango-0.8.9.1 lib/cantango/permits/role_permit/builder.rb
cantango-0.8.9 lib/cantango/permits/role_permit/builder.rb
cantango-0.8.8.1 lib/cantango/permits/role_permit/builder.rb
cantango-0.8.8 lib/cantango/permits/role_permit/builder.rb