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.
195 196 197 |
# File 'lib/otto.rb', line 195 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.
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/otto.rb', line 177 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
173 174 175 |
# File 'lib/otto.rb', line 173 def not_found [404, {'Content-Type'=>'text/plain'}, ["Not Found"]] end |
#server_error ⇒ Object
170 171 172 |
# File 'lib/otto.rb', line 170 def server_error [500, {'Content-Type'=>'text/plain'}, ["Server error"]] end |