Module: Otto::Static
Instance Method Summary collapse
-
#indifferent_hash ⇒ Object
Creates a Hash with indifferent access.
-
#indifferent_params(params) ⇒ Object
Enable string or symbol key access to the nested params hash.
- #not_found ⇒ Object
- #server_error ⇒ Object
Instance Method Details
#indifferent_hash ⇒ Object
Creates a Hash with indifferent access.
212 213 214 |
# File 'lib/otto.rb', line 212 def indifferent_hash Hash.new {|hash,key| hash[key.to_s] if Symbol === key } end |
#indifferent_params(params) ⇒ Object
Enable string or symbol key access to the nested params hash.
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
# File 'lib/otto.rb', line 194 def indifferent_params(params) if params.is_a?(Hash) params = indifferent_hash.merge(params) params.each do |key, value| next unless value.is_a?(Hash) || value.is_a?(Array) params[key] = indifferent_params(value) end elsif params.is_a?(Array) params.collect! do |value| if value.is_a?(Hash) || value.is_a?(Array) indifferent_params(value) else value end end end end |
#not_found ⇒ Object
190 191 192 |
# File 'lib/otto.rb', line 190 def not_found [404, {'Content-Type'=>'text/plain'}, ["Not Found"]] end |
#server_error ⇒ Object
187 188 189 |
# File 'lib/otto.rb', line 187 def server_error [500, {'Content-Type'=>'text/plain'}, ["Server error"]] end |