<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html><head> <title>Class: P4Table</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel=StyleSheet href=".././rdoc-style.css" type="text/css" media="screen" /> <script type="text/javascript" language="JavaScript"> <!-- function popCode(url) { window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400") } //--> </script> </head> <body bgcolor="white"> <table summary="Information on class" width="100%" border="0" cellspacing="0"> <tr class="title-row"> <td class="big-title-font"> <sup><font color="aqua">Class</font></sup> P4Table </td> <td align="right"> <table summary="layout" cellspacing="0" cellpadding="2"> <tr valign="top"> <td class="small-title-font">In:</td> <td class="small-title-font"> <a href="../files/P4table_rb.html" class="aqua"> P4table.rb </a> <br /> </td> </tr> <tr> <td class="small-title-font">Parent:</td> <td class="small-title-font"> Object </td> </tr> </table> </td> </tr> </table> <!-- banner header --> <div class="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> <table summary="Methods" cellpadding="5" width="100%"> <tr><td class="tablesubtitle">Methods</td></tr> </table> <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> <table summary="Attributes" cellpadding="5" width="100%"> <tr><td class="tablesubtitle">Attributes</td></tr> </table> <table summary="Attribute details" cellspacing="5"> <tr valign="top"> <td class="attr-name">:name</td> <td align="center" class="attr-rw"> [R] </td> <td></td> </tr> </table> <table summary="Method list" cellpadding="5" width="100%"> <tr><td class="tablesubtitle">Public Class methods</td></tr> </table> <table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0"> <tr><td class="methodtitle"> <a name="M000028"></a> <b>new</b>( name ) </td></tr> </table> <div class="description"> <p> Construct a new <a href="P4Table.html">P4Table</a> object for the named table </p> </div> <pre class="source"> <span class="cmt"># File P4table.rb, line 712</span> <span class="kw">def</span> initialize( name ) @name = name <span class="kw">end</span> </pre> <table summary="Method list" cellpadding="5" width="100%"> <tr><td class="tablesubtitle">Public Instance methods</td></tr> </table> <table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0"> <tr><td class="methodtitle"> <a name="M000029"></a> <b>new_record</b>() </td></tr> </table> <div class="description"> <p> Add a new record to the table. Returns the record for editing. Note the record is not saved until you call P4Record#save </p> </div> <pre class="source"> <span class="cmt"># File P4table.rb, line 722</span> <span class="kw">def</span> new_record P4Record.create( <span class="kw">self</span> ) <span class="kw">end</span> </pre> <table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0"> <tr><td class="methodtitle"> <a name="M000030"></a> <b>load_record</b>( seq ) </td></tr> </table> <div class="description"> <p> Load an existing record from the repository </p> </div> <pre class="source"> <span class="cmt"># File P4table.rb, line 729</span> <span class="kw">def</span> load_record( seq ) P4Record.load( P4RecId.new( <span class="kw">self</span>, seq ) ) <span class="kw">end</span> </pre> <table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0"> <tr><td class="methodtitle"> <a name="M000031"></a> <b>query</b>( expr ) </td></tr> </table> <div class="description"> <p> Search for matching records. </p> </div> <pre class="source"> <span class="cmt"># File P4table.rb, line 736</span> <span class="kw">def</span> query( expr ) P4Record.query( name, expr ) <span class="kw">end</span> </pre> <table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0"> <tr><td class="methodtitle"> <a name="M000032"></a> <b>storage_map</b>( id ) </td></tr> </table> <div class="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> </div> <pre class="source"> <span class="cmt"># File P4table.rb, line 759</span> <span class="kw">def</span> storage_map( id ) <span class="kw">return</span> [ id.table.name ] <span class="kw">end</span> </pre> </body>
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 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. |
||
#1 | 3093 | Tony Smith |
Move docs for P4Table in preparation for upcoming docs for specsaver.rb |
||
//guest/tony_smith/perforce/utils/doc/classes/P4Table.html | |||||
#1 | 2396 | Tony Smith |
Add RDoc documentation for P4Table.rb. Very pretty. |