Class: Quince::SinatraApp

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/quince/sinatra.rb

Class Method Summary collapse

Class Method Details

.create_route_handler(verb:, route:, &blck) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/quince/sinatra.rb', line 5

def create_route_handler(verb:, route:, &blck)
  meth = case verb
    when :POST, :post
      :post
    when :GET, :get
      :get
    else
      raise "invalid verb"
    end

  public_send meth, route do
    Quince.to_html(blck.call(binding))
  ensure
    Thread.current[:request_binding] = nil
    Thread.current[:params] = nil
  end
end