Sha256: b79362532ebeff5acfae636b3746b810b782d26ce59ba051a935a9b8a7897ce1

Contents?: true

Size: 512 Bytes

Versions: 7

Compression:

Stored size: 512 Bytes

Contents

# frozen_string_literal: true

require 'proxes/policies/request_policy'

module ProxES
  class Request
    class StatsPolicy < RequestPolicy
      class Scope < RequestPolicy::Scope
        def resolve
          return [] 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/stats_policy.rb
proxes-0.9.1 lib/proxes/policies/request/stats_policy.rb
proxes-0.9.0 lib/proxes/policies/request/stats_policy.rb
proxes-0.8.6 lib/proxes/policies/request/stats_policy.rb
proxes-0.8.5 lib/proxes/policies/request/stats_policy.rb
proxes-0.8.4 lib/proxes/policies/request/stats_policy.rb
proxes-0.8.3 lib/proxes/policies/request/stats_policy.rb