Class: Knjappserver::ERBHandler

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

Instance Method Summary collapse

Constructor Details

#initializeERBHandler

Returns a new instance of ERBHandler.



2
3
4
# File 'lib/include/class_erbhandler.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/include/class_erbhandler.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/include/class_erbhandler.rb', line 24

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