Sha256: 233db982a6098eb7888c0ef6a88e052120bab274c2f8eb03f1ff9903c3da7cbe

Contents?: true

Size: 510 Bytes

Versions: 5

Compression:

Stored size: 510 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 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/stats_policy.rb
proxes-0.8.1 lib/proxes/policies/request/stats_policy.rb
proxes-0.8.0 lib/proxes/policies/request/stats_policy.rb
proxes-0.7.1 lib/proxes/policies/request/stats_policy.rb
proxes-0.7.0 lib/proxes/policies/request/stats_policy.rb