Sha256: bef7305db4114e3f481b25bc60bc15b5d09a6999ed7c04627f82a48995a4bd25

Contents?: true

Size: 516 Bytes

Versions: 7

Compression:

Stored size: 516 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 request.index, patterns
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
proxes-0.9.2 lib/proxes/policies/request/search_policy.rb
proxes-0.9.1 lib/proxes/policies/request/search_policy.rb
proxes-0.9.0 lib/proxes/policies/request/search_policy.rb
proxes-0.8.6 lib/proxes/policies/request/search_policy.rb
proxes-0.8.5 lib/proxes/policies/request/search_policy.rb
proxes-0.8.4 lib/proxes/policies/request/search_policy.rb
proxes-0.8.3 lib/proxes/policies/request/search_policy.rb