<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Class: P4Table</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"> <h1>P4Table <sup class="type-note">(Class)</sup></h1> <table class="header-table"> <tr class="top-aligned-row"> <td><strong>In:</strong></td> <td> <a href="../files/p4table_rb.html"> p4table.rb </a> <br /> </td> </tr> <tr class="top-aligned-row"> <td><strong>Parent:</strong></td> <td> Object </td> </tr> </table> </div> <!-- banner header --> <div id="bodyContent"> <div id="contextContent"> <div id="description"> <p> Base class for all table classes. All user defined tables should be derived from this class. At the bare minimum you should provide an initialize() that removes the need for the table name to be specified at construction. Something like: </p> <pre> class MyTable < P4Table def initialize super( "mytable" ) end end </pre> <p> You should also make sure that you are handling P4Exceptions to trap and report Perforce errors if they occur. </p> </div> <div id="method-list"> <h2 class="section-bar">Methods</h2> <div class="name-list"> <a href="#M000030">load_record</a> <a href="#M000028">new</a> <a href="#M000029">new_record</a> <a href="#M000031">query</a> <a href="#M000032">storage_map</a> </div> </div> <div id="attribute-list"> <h2 class="section-bar">Attributes</h2> <div class="name-list"> <table> <tr class="top-aligned-row context-row"> <td class="context-item-name">name</td> <td class="context-item-value"> [R] </td> <td class="context-item-desc"></td> </tr> </table> </div> </div> </div> <!-- if includes --> <!-- if method_list --> <div id="methods"> <h2 class="section-bar">Public Class methods</h2> <div id="method-M000028" class="method-detail"> <a name="M000028"></a> <div class="method-heading"> <a href="#M000028" class="method-signature"> <span class="method-name">new</span><span class="method-args">( name )</span> </a> </div> <div class="method-description"> <p> Construct a new <a href="P4Table.html">P4Table</a> object for the named table </p> <p><a class="source-toggle" href="#" onclick="toggleCode('M000028-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000028-source"> <pre> <span class="ruby-comment cmt"># File p4table.rb, line 712</span> 712: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>( <span class="ruby-identifier">name</span> ) 713: <span class="ruby-ivar">@name</span> = <span class="ruby-identifier">name</span> 714: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <h2 class="section-bar">Public Instance methods</h2> <div id="method-M000030" class="method-detail"> <a name="M000030"></a> <div class="method-heading"> <a href="#M000030" class="method-signature"> <span class="method-name">load_record</span><span class="method-args">( seq )</span> </a> </div> <div class="method-description"> <p> Load an existing record from the repository </p> <p><a class="source-toggle" href="#" onclick="toggleCode('M000030-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000030-source"> <pre> <span class="ruby-comment cmt"># File p4table.rb, line 729</span> 729: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">load_record</span>( <span class="ruby-identifier">seq</span> ) 730: <span class="ruby-constant">P4Record</span>.<span class="ruby-identifier">load</span>( <span class="ruby-constant">P4RecId</span>.<span class="ruby-identifier">new</span>( <span class="ruby-keyword kw">self</span>, <span class="ruby-identifier">seq</span> ) ) 731: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div id="method-M000029" class="method-detail"> <a name="M000029"></a> <div class="method-heading"> <a href="#M000029" class="method-signature"> <span class="method-name">new_record</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Add a new record to the table. Returns the record for editing. Note the record is not saved until you call <a href="P4Record.html#M000047">P4Record#save</a> </p> <p><a class="source-toggle" href="#" onclick="toggleCode('M000029-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000029-source"> <pre> <span class="ruby-comment cmt"># File p4table.rb, line 722</span> 722: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">new_record</span> 723: <span class="ruby-constant">P4Record</span>.<span class="ruby-identifier">create</span>( <span class="ruby-keyword kw">self</span> ) 724: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div id="method-M000031" class="method-detail"> <a name="M000031"></a> <div class="method-heading"> <a href="#M000031" class="method-signature"> <span class="method-name">query</span><span class="method-args">( expr )</span> </a> </div> <div class="method-description"> <p> Search for matching records. </p> <p><a class="source-toggle" href="#" onclick="toggleCode('M000031-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000031-source"> <pre> <span class="ruby-comment cmt"># File p4table.rb, line 736</span> 736: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">query</span>( <span class="ruby-identifier">expr</span> ) 737: <span class="ruby-constant">P4Record</span>.<span class="ruby-identifier">query</span>( <span class="ruby-identifier">name</span>, <span class="ruby-identifier">expr</span> ) 738: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div id="method-M000032" class="method-detail"> <a name="M000032"></a> <div class="method-heading"> <a href="#M000032" class="method-signature"> <span class="method-name">storage_map</span><span class="method-args">( id )</span> </a> </div> <div class="method-description"> <p> Return an array of directory components representing the path where the files for this object should be stored. This allows you to tweak the directory structure your files are stored in so you don’t end up with 1000’s of files in a single directory. </p> <p> It is intended that you override this method in your derived classes. Note that you can change the storage map for a table at any time without affecting existing records. This is because the file paths for existing records are stored in the job and only the file paths for new records will be computed using <a href="P4Table.html#M000032">storage_map</a>() </p> <p> For example, to group records by the year and month in which they were created you could use this: </p> <pre> def storage_map( id ) Time.now.to_a[4,2].reverse + [ id.table.name ] end </pre> <p><a class="source-toggle" href="#" onclick="toggleCode('M000032-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000032-source"> <pre> <span class="ruby-comment cmt"># File p4table.rb, line 759</span> 759: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">storage_map</span>( <span class="ruby-identifier">id</span> ) 760: <span class="ruby-keyword kw">return</span> [ <span class="ruby-identifier">id</span>.<span class="ruby-identifier">table</span>.<span class="ruby-identifier">name</span> ] 761: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> </div> </div> <div id="validator-badges"> <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p> </div> </body> </html>
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 4678 | Tony Smith |
Update p4table.rb to use the new spec parsing and formatting features of P4Ruby. This means we now only need one Perforce client instance to handle specs in both hash form and text form. |
||
#1 | 4677 | Tony Smith |
Move P4table.rb to the P4Ruby library and rename it to p4table.rb instead. There's an update coming so this is just the move. |