Sha256: 238629cd63027d8a9d5f7c44f3200863b5f7bbe1610793141c88d7552f333feb

Contents?: true

Size: 514 Bytes

Versions: 5

Compression:

Stored size: 514 Bytes

Contents

# frozen_string_literal: true

require 'proxes/policies/request_policy'

module ProxES
  class Request
    class SearchPolicy < RequestPolicy
      class Scope < RequestPolicy::Scope
        def resolve
          return false if user.nil?

          patterns = Permission.for_user(user, 'INDEX').map do |permission|
            permission.pattern.gsub(/\{user.(.*)\}/) { |_match| user.send(Regexp.last_match[1].to_sym) }
          end
          filter scope.index, patterns
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
proxes-0.8.2 lib/proxes/policies/request/search_policy.rb
proxes-0.8.1 lib/proxes/policies/request/search_policy.rb
proxes-0.8.0 lib/proxes/policies/request/search_policy.rb
proxes-0.7.1 lib/proxes/policies/request/search_policy.rb
proxes-0.7.0 lib/proxes/policies/request/search_policy.rb