Sha256: c3e1dca315ebccdde95dbbfa624a6c9a68b4279f0a101d8de925bafe252d7135

Contents?: true

Size: 455 Bytes

Versions: 2

Compression:

Stored size: 455 Bytes

Contents

# frozen_string_literal: true
module ProxES
  class Request
    class StatsPolicy < RequestPolicy
      class Scope < RequestPolicy::Scope
        def resolve
          patterns = ProxES::Permission.where(verb: 'INDEX', role: user.roles).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

2 entries across 2 versions & 1 rubygems

Version Path
proxes-0.3.1 lib/proxes/policies/request/stats_policy.rb
proxes-0.3.0 lib/proxes/policies/request/stats_policy.rb