Module: HaveAPI::Server::DocHelpers
- Defined in:
- lib/haveapi/server.rb
Instance Method Summary collapse
Instance Method Details
#escape_html(v) ⇒ Object
301 302 303 304 305 |
# File 'lib/haveapi/server.rb', line 301 def escape_html(v) return '' if v.nil? CGI.escapeHTML(v.to_s) end |
#format_param_type(param) ⇒ Object
275 276 277 278 279 |
# File 'lib/haveapi/server.rb', line 275 def format_param_type(param) return param[:type] if param[:type] != 'Resource' "<a href=\"#root-#{param[:resource].join('-')}-show\">#{param[:type]}</a>" end |
#format_validators(validators) ⇒ Object
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
# File 'lib/haveapi/server.rb', line 281 def format_validators(validators) ret = '' return ret if validators.nil? validators.each do |name, opts| ret += "<h5>#{escape_html(name.to_s.capitalize)}</h5>" ret += '<dl>' if opts.respond_to?(:each_pair) opts.each_pair do |k, v| ret += "<dt>#{escape_html(k)}</dt><dd>#{escape_html(v.to_s)}</dd>" end else ret += "<dt>description</dt><dd>#{escape_html(opts.to_s)}</dd>" end ret += '</dl>' end ret end |