GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Util.extract()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 4
rs 10
1
module Route4me
2
  module Util
3
    def self.extract(params, keys)
4
      s = params.select{|k,v| keys.include? k.to_sym }
5
      Hash[s.map{|k, v| [k.to_sym, v] }]
6
    end
7
8
    def self.url_encode(key)
9
      URI.escape(key.to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
10
    end
11
12
    def self.symbolize_names(object)
13
      case object
14
      when Hash
15
        new = {}
16
        object.each do |key, value|
17
          key = (key.to_sym rescue key) || key
18
          new[key] = symbolize_names(value)
19
        end
20
        new
21
      when Array
22
        object.map { |value| symbolize_names(value) }
23
      else
24
        object
25
      end
26
    end
27
  end
28
end
29