Sha256: 2097aafd47395189ea05249f56798815715e213090039ea9d256a95d3cfe3f46
Contents?: true
Size: 770 Bytes
Versions: 2
Compression:
Stored size: 770 Bytes
Contents
# frozen_string_literal: true module Pundit module Matchers module Utils # Collects all details about given policy class. class PolicyInfo attr_reader :policy def initialize(policy) @policy = policy end def actions @actions ||= begin policy_methods = @policy.public_methods - Object.instance_methods policy_methods.grep(/\?$/).sort.map { |policy_method| policy_method.to_s.delete_suffix('?').to_sym } end end def permitted_actions @permitted_actions ||= actions.select { |action| policy.public_send("#{action}?") } end def forbidden_actions actions - permitted_actions end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pundit-matchers-2.3.0 | lib/pundit/matchers/utils/policy_info.rb |
pundit-matchers-2.2.0 | lib/pundit/matchers/utils/policy_info.rb |