Welcome to mirror list, hosted at ThFree Co, Russian Federation.

action_dispatch_journey_formatter.rb « patch « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2d3b7bb99232fd1340cb7cf947a69bb8aa71e1f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# frozen_string_literal: true

module Gitlab
  module Patch
    module ActionDispatchJourneyFormatter
      def self.prepended(mod)
        mod.alias_method(:old_missing_keys, :missing_keys)
        mod.remove_method(:missing_keys)
      end

      private

      def missing_keys(route, parts)
        missing_keys = nil
        tests = route.path.requirements_for_missing_keys_check
        route.required_parts.each do |key|
          case tests[key]
          when nil
            unless parts[key]
              missing_keys ||= []
              missing_keys << key
            end
          else
            unless tests[key].match?(parts[key])
              missing_keys ||= []
              missing_keys << key
            end
          end
        end
        missing_keys
      end
    end
  end
end