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
78 79 80 81 82 |
# File 'lib/swirl/helpers.rb', line 78 def self.camalize(stringish) head, tail = stringish.to_s.split("_") rest = Array(tail).map! {|part| part.capitalize } [head, *rest].join end |
.new(response) ⇒ Object
70 71 72 73 74 75 76 |
# File 'lib/swirl/helpers.rb', line 70 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 |