Module: Swirl::Helpers::Slop
- Defined in:
- lib/swirl/helpers.rb
Defined Under Namespace
Classes: InvalidKey
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.camalize(stringish) ⇒ Object
96 97 98 99 100 |
# File 'lib/swirl/helpers.rb', line 96 def self.camalize(stringish) head, tail = stringish.to_s.split("_") rest = Array(tail).map! {|part| part.capitalize } [head, *rest].join end |
.new(response) ⇒ Object
88 89 90 91 92 93 94 |
# File 'lib/swirl/helpers.rb', line 88 def self.new(response) sloppy = Hash.new do |hash, key| camalized = Slop.camalize(key) raise InvalidKey, key if !response.has_key?(camalized) response[camalized] end end |