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 object.
7

VERSION

9       version 0.60
10

SYNOPSIS

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

DESCRIPTION

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

METHODS

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

SEE ALSO

72       RT::Client::REST::Object, RT::Client::REST.
73

AUTHOR

75       Dmitri Tikhonov
76
78       This software is copyright (c) 2020, 2018 by Dmitri Tikhonov.
79
80       This is free software; you can redistribute it and/or modify it under
81       the same terms as the Perl 5 programming language system itself.
82
83
84
85perl v5.34.0                      2022-01-21 RT::Client::REST::SearchResult(3)
Impressum