Class: Server

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/server_skeleton/server.rb

Overview

Our server, a Sinatra app

Instance Method Summary collapse

Instance Method Details

#renderersObject

For now, the only extra information being sent in ‘request’ is the method ‘slim’, which would otherwise be unavailable in the scope of a different class.



63
64
65
66
67
# File 'lib/server_skeleton/server.rb', line 63

def renderers
  OpenStruct.new(
    slim: method(:slim)
  )
end

#request_objObject

The ‘request’ variable is passed along to route handlers Some extra information is attached to make for a simpler API



52
53
54
55
56
57
58
# File 'lib/server_skeleton/server.rb', line 52

def request_obj
  if !defined?(request.renderers)
    _renderers = method(:renderers)
    request.define_singleton_method(:renderers) { _renderers.call }
  end
  request
end