Class: Hayabusa::Erb_handler

Inherits:
Object
  • Object
show all
Defined in:
lib/hayabusa_erb_handler.rb

Instance Method Summary collapse

Constructor Details

#initializeErb_handler

Returns a new instance of Erb_handler.



2
3
4
# File 'lib/hayabusa_erb_handler.rb', line 2

def initialize
  @connected = {}
end

Instance Method Details

#erb_handler(httpsess) ⇒ Object



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

def erb_handler(httpsess)
  eruby = httpsess.eruby
  
  if !@connected.key?(eruby.__id__)
    eruby.connect("error", &self.method(:on_error))
    @connected[eruby.__id__] = true
  end
  
  if !File.exists?(httpsess.page_path)
    eruby.import("#{File.dirname(__FILE__)}/../pages/error_notfound.rhtml")
  else
    eruby.import(httpsess.page_path)
  end
  
  httpsess.resp.status = 500 if eruby.error
end

#on_error(e) ⇒ Object

Handels the event when an error in the eruby-instance occurs.



24
25
26
# File 'lib/hayabusa_erb_handler.rb', line 24

def on_error(e)
  _hb.handle_error(e)
end