Module: Aitch::Utils

Extended by:
Utils
Included in:
Utils
Defined in:
lib/aitch/utils.rb

Constant Summary collapse

MATCHER =
/(?<=.)(URI|[A-Z])/

Instance Method Summary collapse

Instance Method Details

#build_query(data) ⇒ Object



23
24
25
# File 'lib/aitch/utils.rb', line 23

def build_query(data)
  data.to_query
end

#symbolize_keys(hash) ⇒ Object



17
18
19
20
21
# File 'lib/aitch/utils.rb', line 17

def symbolize_keys(hash)
  hash.each_with_object({}) do |(key, value), buffer|
    buffer[key.to_sym] = value
  end
end

#underscore(string) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/aitch/utils.rb', line 9

def underscore(string)
  string = string.gsub(MATCHER) do |char|
    "_#{char}"
  end

  string.downcase
end