module Alexa::Utils

Public Class Methods

camelize(string) click to toggle source
# File lib/alexa/utils.rb, line 13
def camelize(string)
  string.split("_").map { |w| w.capitalize }.join
end
safe_retrieve(hash, *keys) click to toggle source
# File lib/alexa/utils.rb, line 3
def safe_retrieve(hash, *keys)
  return if !hash.kind_of?(Hash) || !hash.has_key?(keys.first)

  if keys.size == 1
    hash[keys.first]
  elsif keys.size > 1
    Alexa::Utils.safe_retrieve(hash[keys.first], *keys[1..-1])
  end
end

Private Instance Methods

camelize(string) click to toggle source
# File lib/alexa/utils.rb, line 13
def camelize(string)
  string.split("_").map { |w| w.capitalize }.join
end
safe_retrieve(hash, *keys) click to toggle source
# File lib/alexa/utils.rb, line 3
def safe_retrieve(hash, *keys)
  return if !hash.kind_of?(Hash) || !hash.has_key?(keys.first)

  if keys.size == 1
    hash[keys.first]
  elsif keys.size > 1
    Alexa::Utils.safe_retrieve(hash[keys.first], *keys[1..-1])
  end
end