Class: Cuba::Tools::Widget::Responder

Inherits:
Object
  • Object
show all
Defined in:
lib/cuba/tools/widget/responder.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ Responder

Returns a new instance of Responder.



4
5
6
7
# File 'lib/cuba/tools/widget/responder.rb', line 4

def initialize(app, env)
  @app = app
  @env = env
end

Instance Method Details

#respondObject



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/cuba/tools/widget/responder.rb', line 9

def respond
  if widget_path
    widget_name, widget_event, events = Widget.load_all @app, req, res

    events.trigger widget_name, widget_event, req.params
    # res.write "$('head > meta[name=csrf-token]').attr('content', '#{csrf_token}');"
    res.write '$(document).trigger("page:change");'
  end

  res.finish
end