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



25
26
27
# File 'lib/aitch/utils.rb', line 25

def build_query(data)
  data.to_query
end

#symbolize_keys(hash) ⇒ Object



19
20
21
22
23
# File 'lib/aitch/utils.rb', line 19

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

#underscore(string) ⇒ Object



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

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

  string.downcase
end