NAME
RT::Client::REST::Object -- base class for RT objects.
SYNOPSIS
# Create a new type
package RT::Client::REST::MyType;
use base qw(RT::Client::REST::Object);
sub _attributes {{
myattribute => {
validation => {
type => SCALAR,
},
},
}}
sub rt_type { "mytype" }
1;
DESCRIPTION
The RT::Client::REST::Object module is a superclass providing a whole bunch of class and object methods in order to streamline the development of RT's REST client interface.
METHODS
- new
-
Constructor
- _generate_methods
-
This class method generates accessors and mutators based on _attributes method which your class should provide. For items that are lists, 'add_' and 'delete_' methods are created. For instance, the following two attributes specified in _attributes will generate methods 'creator', 'cc', 'add_cc', and 'delete_cc':
creator => { validation => { type => SCALAR }, }, cc => { list => 1, validation => { type => ARRAYREF }, },
Note that accessors/mutators working with 'list' attributes accept and return array references, whereas convenience methods 'add_*' and 'delete_*' accept lists of items.
- _mark_dirty($attrname)
-
Mark an attribute as dirty.
- _dirty
-
Return the list of dirty attributes.
- to_form($all)
-
Convert the object to 'form' (used by REST protocol). This is done based on _attributes method. If
$all
is true, create a form from all of the object's attributes, otherwise use only dirty (see _dirty method) attributes. Defaults to the latter. - from_form
-
Set object's attributes from form received from RT server.
- retrieve
-
Retrieve object's attributes. Note that 'id' attribute must be set for this to work.
- store
-
Store the object. If 'id' is set, this is an update; otherwise, a new object is created and the 'id' attribute is set. Note that only changed (dirty) attributes are sent to the server.
- param($name, $value)
-
Set an arbitrary parameter.
- cf([$name, [$value]])
-
Given no arguments, returns the list of custom field names. With one argument, returns the value of custom field
$name
. With two arguments, sets custom field$name
to$value
. - rt
-
Get or set the 'rt' object, which should be of type RT::Client::REST.
SEE ALSO
AUTHOR
Dmitri Tikhonov <dtikhonov@yahoo.com>