Top Level Namespace

Defined Under Namespace

Modules: Quince

Instance Method Summary collapse

Instance Method Details

#expose(component, at:) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/quince/sinatra.rb', line 26

def expose(component, at:)
  Quince::SinatraApp.get(at) do
    Thread.current[:request_binding] = binding
    Thread.current[:params] = binding.receiver.params
    comp = component.instance_of?(Class) ? component.create : component
    comp.instance_variable_set :@render_with, :render
    Quince.to_html(comp)
  ensure
    Thread.current[:request_binding] = nil
    Thread.current[:params] = nil
  end
end