Class: TDiary::Dispatcher::UpdateMain
- Inherits:
-
Object
- Object
- TDiary::Dispatcher::UpdateMain
- Defined in:
- lib/tdiary/dispatcher/update_main.rb
Instance Attribute Summary collapse
-
#cgi ⇒ Object
readonly
Returns the value of attribute cgi.
-
#conf ⇒ Object
readonly
Returns the value of attribute conf.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#tdiary ⇒ Object
readonly
Returns the value of attribute tdiary.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(request) ⇒ UpdateMain
constructor
A new instance of UpdateMain.
- #run ⇒ Object
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
#cgi ⇒ Object (readonly)
Returns the value of attribute cgi.
8 9 10 |
# File 'lib/tdiary/dispatcher/update_main.rb', line 8 def cgi @cgi end |
#conf ⇒ Object (readonly)
Returns the value of attribute conf.
8 9 10 |
# File 'lib/tdiary/dispatcher/update_main.rb', line 8 def conf @conf end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
8 9 10 |
# File 'lib/tdiary/dispatcher/update_main.rb', line 8 def params @params end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
8 9 10 |
# File 'lib/tdiary/dispatcher/update_main.rb', line 8 def request @request end |
#tdiary ⇒ Object (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
#run ⇒ Object
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..map(&:to_s)) if tdiary && tdiary..size > 0 res end end |