module Render::Document
Document
renders a file to an HTML representation @author Bryan T. Meyers
Public Class Methods
do_read(actions, context, specific)
click to toggle source
Renders a document or listing to HTML @param [Array] actions the actions allowed for this URI @param [Wire::Context] context the context for this request @param [Symbol] specific the type of read to perform @return [Response] a Rack Response triplet, or status code
# File lib/app/render/document.rb, line 27 def self.do_read(actions, context, specific) response = context.forward(specific) mime = response[1]['content-type'] renderer = nil context.closet.renderers.each do |k, c| if c['mimes'].include? mime renderer = c end end if renderer template = renderer['partial'] template.render(self, { actions: actions, context: context, mime: mime, response: response[2] }) else response end end
invoke(actions, context)
click to toggle source
Proxy method used when routing @param [Array] actions the allowed actions for this URI @param [Hash] context the context for this request @return [Response] a Rack Response triplet, or status code
# File lib/app/render/document.rb, line 51 def self.invoke(actions, context) case context.action when :create, :update, :delete context.forward(context.action) when :read if context.id do_read(actions, context, :read) else do_read(actions, context, :readAll) end else 405 end end