1RT::Client::REST::SearcUhsReersuClotn(t3r)ibuted Perl DoRcTu:m:eCnltiaetnito:n:REST::SearchResult(3)
2
3
4

NAME

6       RT::Client::REST::SearchResult -- Search results representation.
7

SYNOPSIS

9         my $iterator = $search->get_iterator;
10         my $count = $iterator->count;
11
12         while (defined(my $obj = &$iterator)) {
13           # do something with the $obj
14         }
15

DESCRIPTION

17       This class is a representation of a search result.  This is the type of
18       the object you get back when you call method "search()" on
19       RT::Client::REST::Object-derived objects.  It makes it easy to iterate
20       over results and find out just how many there are.
21

METHODS

23       count
24           Returns the number of search results.  This number will always be
25           the same unless you stick your fat dirty fingers into the object
26           and abuse it.  This number is not affected by calls to
27           "get_iterator()".
28
29       get_iterator
30           Returns a reference to a subroutine which is used to iterate over
31           the results.
32
33           Evaluating it in scalar context, returns the next object or "undef"
34           if all the results have already been iterated over.  Note that for
35           each object to be instantiated with correct values, retrieve()
36           method is called on the object before returning it to the caller.
37
38           Evaluating the subroutine reference in list context returns a list
39           of all results fully instantiated.  WARNING: this may be expensive,
40           as each object is issued retrieve() method.  Subsequent calls to
41           the iterator result in empty list.
42
43           You may safely mix calling the iterator in scalar and list context.
44           For example:
45
46             $iterator = $search->get_iterator;
47
48             $first = &$iterator;
49             $second = &$iterator;
50             @the_rest = &$iterator;
51
52           You can get as many iterators as you want -- they will not step on
53           each other's toes.
54
55       new You should not have to call it yourself, but just for the sake of
56           completeness, here are the arguments:
57
58             my $search = RT::Client::REST::SearchResult->new(
59               ids => [1 .. 10],
60               object => sub {       # Yup, that's a closure.
61                 RT::Client::REST::Ticket->new(
62                   id => shift,
63                   rt => $rt,
64                 );
65               },
66             );
67

SEE ALSO

69       RT::Client::REST::Object, RT::Client::REST.
70

AUTHOR

72       Dmitri Tikhonov <dtikhonov@yahoo.com>
73
74
75
76perl v5.12.0                      2007-12-23 RT::Client::REST::SearchResult(3)
Impressum