Module: HaveAPI::Server::DocHelpers
- Defined in:
- lib/haveapi/server.rb
Instance Method Summary collapse
Instance Method Details
#escape_html(v) ⇒ Object
249 250 251 252 253 |
# File 'lib/haveapi/server.rb', line 249 def escape_html(v) return '' if v.nil? CGI.escapeHTML(v.to_s) end |
#format_param_type(param) ⇒ Object
223 224 225 226 227 |
# File 'lib/haveapi/server.rb', line 223 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
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
# File 'lib/haveapi/server.rb', line 229 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 |