Sha256: ac7604fc793f0b5aa54ce22a3e63f49a6a5f9a984a552406b2b9cbb5a5f5631b

Contents?: true

Size: 897 Bytes

Versions: 7

Compression:

Stored size: 897 Bytes

Contents

# frozen_string_literal: true

module Pundit
  module Matchers
    module Utils
      module AllActions
        # Parent class for specific all_action matcher. Should not be used directly.
        #
        # Expects methods in child class:
        # * actual_actions - list of actions which actually matches expected type.
        class ActionsMatcher
          attr_reader :policy_info

          def initialize(policy)
            @policy_info = PolicyInfo.new(policy)
          end

          def match?
            missed_expected_actions.empty?
          end

          def missed_expected_actions
            @missed_expected_actions ||= expected_actions - actual_actions
          end

          def policy
            policy_info.policy
          end

          private

          def expected_actions
            policy_info.actions
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pundit-matchers-2.3.0 lib/pundit/matchers/utils/all_actions/actions_matcher.rb
pundit-matchers-2.2.0 lib/pundit/matchers/utils/all_actions/actions_matcher.rb
pundit-matchers-2.1.0 lib/pundit/matchers/utils/all_actions/actions_matcher.rb
pundit-matchers-2.0.0 lib/pundit/matchers/utils/all_actions/actions_matcher.rb
pundit-matchers-1.9.0 lib/pundit/matchers/utils/all_actions/actions_matcher.rb
pundit-matchers-1.8.4 lib/pundit/matchers/utils/all_actions/actions_matcher.rb
pundit-matchers-1.8.3 lib/pundit/matchers/utils/all_actions/actions_matcher.rb