Flowdock
method

compile

Importance_0
Ruby on Rails latest stable (v5.2.3) - 0 notes - Class: CompiledFilter
compile(filters) public

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File actionpack/lib/action_dispatch/http/parameter_filter.rb, line 25
        def self.compile(filters)
          return lambda { |params| params.dup } if filters.empty?

          strings, regexps, blocks = [], [], []

          filters.each do |item|
            case item
            when Proc
              blocks << item
            when Regexp
              regexps << item
            else
              strings << Regexp.escape(item.to_s)
            end
          end

          deep_regexps, regexps = regexps.partition { |r| r.to_s.include?("\\.".freeze) }
          deep_strings, strings = strings.partition { |s| s.include?("\\.".freeze) }

          regexps << Regexp.new(strings.join("|".freeze), true) unless strings.empty?
          deep_regexps << Regexp.new(deep_strings.join("|".freeze), true) unless deep_strings.empty?

          new regexps, deep_regexps, blocks
        end
Register or log in to add new notes.