Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > c9ad9a65a400487e90bbcd3a23213842 > files > 20

ruby-activeresource-2.0.2-1mdv2008.1.noarch.rpm

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: ActiveResource</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">ActiveResource</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../files/lib/active_resource/base_rb.html">
                lib/active_resource/base.rb
                </a>
        <br />
                <a href="../files/lib/active_resource/connection_rb.html">
                lib/active_resource/connection.rb
                </a>
        <br />
                <a href="../files/lib/active_resource/custom_methods_rb.html">
                lib/active_resource/custom_methods.rb
                </a>
        <br />
                <a href="../files/lib/active_resource/formats/json_format_rb.html">
                lib/active_resource/formats/json_format.rb
                </a>
        <br />
                <a href="../files/lib/active_resource/formats/xml_format_rb.html">
                lib/active_resource/formats/xml_format.rb
                </a>
        <br />
                <a href="../files/lib/active_resource/formats_rb.html">
                lib/active_resource/formats.rb
                </a>
        <br />
                <a href="../files/lib/active_resource/http_mock_rb.html">
                lib/active_resource/http_mock.rb
                </a>
        <br />
                <a href="../files/lib/active_resource/validations_rb.html">
                lib/active_resource/validations.rb
                </a>
        <br />
                <a href="../files/lib/active_resource/version_rb.html">
                lib/active_resource/version.rb
                </a>
        <br />
                <a href="../files/lib/active_resource_rb.html">
                lib/active_resource.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
A module to support custom REST methods and sub-resources, allowing you to
break out of the &quot;default&quot; REST methods with your own custom
resource requests. For example, say you use Rails to expose a REST service
and configure your routes with:
</p>
<pre>
   map.resources :people, :new =&gt; { :register =&gt; :post },
                          :element =&gt; { :promote =&gt; :put, :deactivate =&gt; :delete }
                          :collection =&gt; { :active =&gt; :get }

 This route set creates routes for the following http requests:

   POST    /people/new/register.xml #=&gt; PeopleController.register
   PUT     /people/1/promote.xml    #=&gt; PeopleController.promote with :id =&gt; 1
   DELETE  /people/1/deactivate.xml #=&gt; PeopleController.deactivate with :id =&gt; 1
   GET     /people/active.xml       #=&gt; PeopleController.active
</pre>
<p>
Using this module, Active Resource can use these custom REST methods just
like the standard methods.
</p>
<pre>
  class Person &lt; ActiveResource::Base
    self.site = &quot;http://37s.sunrise.i:3000&quot;
  end

  Person.new(:name =&gt; 'Ryan).post(:register)  # POST /people/new/register.xml
  # =&gt; { :id =&gt; 1, :name =&gt; 'Ryan' }

  Person.find(1).put(:promote, :position =&gt; 'Manager') # PUT /people/1/promote.xml
  Person.find(1).delete(:deactivate) # DELETE /people/1/deactivate.xml

  Person.get(:active)  # GET /people/active.xml
  # =&gt; [{:id =&gt; 1, :name =&gt; 'Ryan'}, {:id =&gt; 2, :name =&gt; 'Joe'}]
</pre>

    </div>


   </div>


  </div>


    <!-- if includes -->
    <div id="includes">
      <h3 class="section-bar">Included Modules</h3>

      <div id="includes-list">
        <span class="include-name"><a href="ActiveResource/Validations.html">Validations</a></span>
        <span class="include-name"><a href="ActiveResource/CustomMethods.html">CustomMethods</a></span>
      </div>
    </div>

    <div id="section">

    <div id="class-list">
      <h3 class="section-bar">Classes and Modules</h3>

      Module <a href="ActiveResource/CustomMethods.html" class="link">ActiveResource::CustomMethods</a><br />
Module <a href="ActiveResource/Formats.html" class="link">ActiveResource::Formats</a><br />
Module <a href="ActiveResource/Validations.html" class="link">ActiveResource::Validations</a><br />
Class <a href="ActiveResource/BadRequest.html" class="link">ActiveResource::BadRequest</a><br />
Class <a href="ActiveResource/Base.html" class="link">ActiveResource::Base</a><br />
Class <a href="ActiveResource/ClientError.html" class="link">ActiveResource::ClientError</a><br />
Class <a href="ActiveResource/Connection.html" class="link">ActiveResource::Connection</a><br />
Class <a href="ActiveResource/Errors.html" class="link">ActiveResource::Errors</a><br />
Class <a href="ActiveResource/ForbiddenAccess.html" class="link">ActiveResource::ForbiddenAccess</a><br />
Class <a href="ActiveResource/HttpMock.html" class="link">ActiveResource::HttpMock</a><br />
Class <a href="ActiveResource/InvalidRequestError.html" class="link">ActiveResource::InvalidRequestError</a><br />
Class <a href="ActiveResource/Request.html" class="link">ActiveResource::Request</a><br />
Class <a href="ActiveResource/ResourceConflict.html" class="link">ActiveResource::ResourceConflict</a><br />
Class <a href="ActiveResource/ResourceNotFound.html" class="link">ActiveResource::ResourceNotFound</a><br />
Class <a href="ActiveResource/Response.html" class="link">ActiveResource::Response</a><br />
Class <a href="ActiveResource/ServerError.html" class="link">ActiveResource::ServerError</a><br />
Class <a href="ActiveResource/UnauthorizedAccess.html" class="link">ActiveResource::UnauthorizedAccess</a><br />

    </div>




      


    <!-- if method_list -->


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>