class Mindmap::Request

Public Instance Methods

params() click to toggle source
Calls superclass method
# File lib/mindmap/request.rb, line 9
def params
  super.with_indifferent_access
end
response() click to toggle source
# File lib/mindmap/request.rb, line 5
def response
  [200, response_headers, response_body]
end

Private Instance Methods

node() click to toggle source
# File lib/mindmap/request.rb, line 44
def node
  @node ||= node_klass.new(params)
end
node_children() click to toggle source
# File lib/mindmap/request.rb, line 40
def node_children
  @node_children ||= node.children
end
node_klass() click to toggle source
# File lib/mindmap/request.rb, line 48
def node_klass
  (path.camelize + 'Node').constantize
end
response_body() click to toggle source
# File lib/mindmap/request.rb, line 15
def response_body
  [node_children.map { |child| child.render(response_type) }.join]
end
response_format() click to toggle source
# File lib/mindmap/request.rb, line 36
def response_format
  get_header('HTTP_ACCEPT') || 'text/html'
end
response_headers() click to toggle source
# File lib/mindmap/request.rb, line 19
def response_headers
  {
    'Content-Type' => "#{response_format};charset=utf-8"
  }
end
response_type() click to toggle source
# File lib/mindmap/request.rb, line 25
def response_type
  case response_format
  when 'text/html'
    :html
  when 'image/svg+xml'
    :svg
  else
    :html
  end
end