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.
233 234 235 |
# File 'lib/otto.rb', line 233 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.
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
# File 'lib/otto.rb', line 215 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
211 212 213 |
# File 'lib/otto.rb', line 211 def not_found [404, {'Content-Type'=>'text/plain'}, ["Not Found"]] end |
#server_error ⇒ Object
208 209 210 |
# File 'lib/otto.rb', line 208 def server_error [500, {'Content-Type'=>'text/plain'}, ["Server error"]] end |