P4Table (Class)

In: p4table.rb
Parent: Object

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:

 class MyTable < P4Table
   def initialize
     super( "mytable" )
   end
 end

You should also make sure that you are handling P4Exceptions to trap and report Perforce errors if they occur.

Methods

Attributes

name  [R] 

Public Class methods

Construct a new P4Table object for the named table

[Source]

     # File p4table.rb, line 712
712:     def initialize( name )
713:         @name = name
714:     end

Public Instance methods

Load an existing record from the repository

[Source]

     # File p4table.rb, line 729
729:     def load_record( seq )
730:         P4Record.load( P4RecId.new( self, seq ) )
731:     end

Add a new record to the table. Returns the record for editing. Note the record is not saved until you call P4Record#save

[Source]

     # File p4table.rb, line 722
722:     def new_record
723:         P4Record.create( self ) 
724:     end

Search for matching records.

[Source]

     # File p4table.rb, line 736
736:     def query( expr )
737:         P4Record.query( name, expr )
738:     end

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.

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 storage_map()

For example, to group records by the year and month in which they were created you could use this:

  def storage_map( id )
    Time.now.to_a[4,2].reverse + [ id.table.name ]
  end

[Source]

     # File p4table.rb, line 759
759:     def storage_map( id )
760:         return [ id.table.name ]
761:     end

[Validate]