Module: HaveAPI::Server::DocHelpers
- Defined in:
- lib/haveapi/server.rb
Instance Method Summary collapse
Instance Method Details
#escape_html(v) ⇒ Object
211 212 213 214 215 |
# File 'lib/haveapi/server.rb', line 211 def escape_html(v) return '' if v.nil? CGI.escapeHTML(v.to_s) end |
#format_param_type(param) ⇒ Object
185 186 187 188 189 |
# File 'lib/haveapi/server.rb', line 185 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
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/haveapi/server.rb', line 191 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 |