[前][次][番号順一覧][スレッド一覧]

ruby-changes:19500

From: drbrain <ko1@a...>
Date: Fri, 13 May 2011 07:38:51 +0900 (JST)
Subject: [ruby-changes:19500] drbrain:r31540 (trunk): * lib/webrick/httpservlet/erbhandler.rb: Add documentation.

drbrain	2011-05-13 07:37:01 +0900 (Fri, 13 May 2011)

  New Revision: 31540

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=31540

  Log:
    * lib/webrick/httpservlet/erbhandler.rb:  Add documentation.

  Modified files:
    trunk/ChangeLog
    trunk/lib/webrick/httpservlet/erbhandler.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 31539)
+++ ChangeLog	(revision 31540)
@@ -1,3 +1,7 @@
+Fri May 13 07:36:23 2011  Eric Hodel  <drbrain@s...>
+
+	* lib/webrick/httpservlet/erbhandler.rb:  Add documentation.
+
 Fri May 13 07:04:33 2011  Eric Hodel  <drbrain@s...>
 
 	* lib/mathn.rb:  Fix indentation.  Patch by Jason Dew.
Index: lib/webrick/httpservlet/erbhandler.rb
===================================================================
--- lib/webrick/httpservlet/erbhandler.rb	(revision 31539)
+++ lib/webrick/httpservlet/erbhandler.rb	(revision 31540)
@@ -15,12 +15,37 @@
 module WEBrick
   module HTTPServlet
 
+    ##
+    # ERBHandler evaluates an ERB file and returns the result.  This handler
+    # is automatically used if there are .rhtml files in a directory served by
+    # the FileHandler.
+    #
+    # ERBHandler supports GET and POST methods.
+    #
+    # The ERB file is evaluated with the local variables +servlet_request+ and
+    # +servlet_response+ which are a WEBrick::HTTPRequest and
+    # WEBrick::HTTPResponse respectively.
+    #
+    # Example .rhtml file:
+    #
+    #   Request to <%= servlet_request.request_uri %>
+    #
+    #   Query params <%= servlet_request.query.inspect %>
+
     class ERBHandler < AbstractServlet
+
+      ##
+      # Creates a new ERBHandler on +server+ that will evaluate and serve the
+      # ERB file +name+
+
       def initialize(server, name)
         super(server, name)
         @script_filename = name
       end
 
+      ##
+      # Handles GET requests
+
       def do_GET(req, res)
         unless defined?(ERB)
           @logger.warn "#{self.class}: ERB not defined."
@@ -39,9 +64,17 @@
         end
       end
 
+      ##
+      # Handles POST requests
+
       alias do_POST do_GET
 
       private
+
+      ##
+      # Evaluates +erb+ providing +servlet_request+ and +servlet_response+ as
+      # local variables.
+
       def evaluate(erb, servlet_request, servlet_response)
         Module.new.module_eval{
           servlet_request.meta_vars

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]