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



73
74
75
76
77
# File 'lib/swirl/helpers.rb', line 73

def self.camalize(stringish)
  head, tail = stringish.to_s.split("_")
  rest = Array(tail).map! {|part| part.capitalize }
  [head, *rest].join
end

.new(response) ⇒ Object



65
66
67
68
69
70
71
# File 'lib/swirl/helpers.rb', line 65

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

Instance Method Details

#slopify(response) ⇒ Object



79
80
81
# File 'lib/swirl/helpers.rb', line 79

def slopify(response)
  Slop.new(response)
end