Class P4::Spec
Description
The P4::Spec
class is a hash containing key/value
pairs for all the fields in a
Helix Core Server
form. It provides two things over and above its parent class (Hash):
- Fieldname validation. Only valid field names may be set in a
P4::Spec
object. Note that only the field name is validated, not the content. - Accessor methods for easy access to the fields.
Class Methods
new P4::Spec.new( anArray ) -> aP4::Spec
Constructs a new P4::Spec
object given an array of
valid fieldnames.
Instance Methods
spec._<fieldname> -> aValue
Returns the value associated with the field named
<fieldname>. This is equivalent to spec[
"<fieldname>" ]
with the exception that when used
as a method, the fieldnames may be in lowercase regardless of the actual
case of the fieldname.
client = p4.fetch_client()
root = client._root
desc = client._description
spec._<fieldname>= aValue -> aValue
Updates the value of the named field in the spec. Raises a
P4Exception
if the fieldname is not valid for specs
of this type.
client = p4.fetch_client()
client._root = "/home/bruno/new-client"
client._description = "My new client spec"
p4.save_client( client )
spec.permitted_fields -> anArray
Returns an array containing the names of fields that are valid in this spec object. This does not imply that values for all of these fields are actually set in this object, merely that you may choose to set values for any of these fields if you want to.
client = p4.fetch_client()
spec.permitted_fields.each do
| field |
printf ( "%14s = %s\n", field, client[ field ] )
end