Class: TDiary::Dispatcher::UpdateMain

Inherits:
Object
  • Object
show all
Defined in:
lib/tdiary/dispatcher/update_main.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ UpdateMain

Returns a new instance of UpdateMain.



10
11
12
13
14
15
# File 'lib/tdiary/dispatcher/update_main.rb', line 10

def initialize( request )
	@request = request
	@cgi = request.cgi_compat
	@conf = TDiary::Configuration::new( request )
	@params = request.params
end

Instance Attribute Details

#cgiObject (readonly)

Returns the value of attribute cgi.



8
9
10
# File 'lib/tdiary/dispatcher/update_main.rb', line 8

def cgi
  @cgi
end

#confObject (readonly)

Returns the value of attribute conf.



8
9
10
# File 'lib/tdiary/dispatcher/update_main.rb', line 8

def conf
  @conf
end

#paramsObject (readonly)

Returns the value of attribute params.



8
9
10
# File 'lib/tdiary/dispatcher/update_main.rb', line 8

def params
  @params
end

#requestObject (readonly)

Returns the value of attribute request.



8
9
10
# File 'lib/tdiary/dispatcher/update_main.rb', line 8

def request
  @request
end

#tdiaryObject (readonly)

Returns the value of attribute tdiary.



8
9
10
# File 'lib/tdiary/dispatcher/update_main.rb', line 8

def tdiary
  @tdiary
end

Class Method Details

.run(request) ⇒ Object



4
5
6
# File 'lib/tdiary/dispatcher/update_main.rb', line 4

def self.run( request )
	new( request ).run
end

Instance Method Details

#runObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/tdiary/dispatcher/update_main.rb', line 17

def run
	@tdiary = create_tdiary
	begin
		head = {}; body = ''
		body = tdiary.eval_rhtml
		head = {
			'content-type' => 'text/html; charset=UTF-8',
			'content-length' => body.bytesize.to_s,
			'vary' => 'User-Agent'
		}
		body = ( request.head? ? '' : body )
		TDiary::Response.new( body, 200, head )
	rescue TDiary::ForceRedirect
		res = TDiary::Response.new( '', 303, { 'location' => $!.path } )
		res.set_header('Set-Cookie', tdiary.cookies.map(&:to_s)) if tdiary && tdiary.cookies.size > 0
		res
	end
end