Module: Alexa::Utils
- Included in:
- API::Base
- Defined in:
- lib/alexa/utils.rb
Class Method Summary collapse
Class Method Details
.camelize(string) ⇒ Object
13 14 15 |
# File 'lib/alexa/utils.rb', line 13 def camelize(string) string.split("_").map { |w| w.capitalize }.join end |
.safe_retrieve(hash, *keys) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# 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 |