| 
      
            Lines 54-59
          sub new {
      
      
        Link Here
      
     | 
  
        
          | 54 | 
              my ($class) = @_;  | 
          54 | 
              my ($class) = @_;  | 
        
        
          | 55 | 
              my $self = {}; | 
          55 | 
              my $self = {}; | 
        
        
          | 56 | 
           | 
          56 | 
           | 
        
            
               | 
               | 
              57 | 
                  $self->{_iterator} = 0; | 
            
            
              | 58 | 
               | 
            
        
          | 57 | 
              bless( $self, $class );  | 
          59 | 
              bless( $self, $class );  | 
        
        
          | 58 | 
          }  | 
          60 | 
          }  | 
        
        
          | 59 | 
           | 
          61 | 
           | 
        
  
    | 
      
            Lines 67-72
          sub _new_from_dbic {
      
      
        Link Here
      
     | 
  
        
          | 67 | 
              my ( $class, $resultset ) = @_;  | 
          69 | 
              my ( $class, $resultset ) = @_;  | 
        
        
          | 68 | 
              my $self = { _resultset => $resultset }; | 
          70 | 
              my $self = { _resultset => $resultset }; | 
        
        
          | 69 | 
           | 
          71 | 
           | 
        
            
               | 
               | 
              72 | 
                  $self->{_iterator} = 0; | 
            
            
              | 73 | 
               | 
            
        
          | 70 | 
              bless( $self, $class );  | 
          74 | 
              bless( $self, $class );  | 
        
        
          | 71 | 
          }  | 
          75 | 
          }  | 
        
        
          | 72 | 
           | 
          76 | 
           | 
        
  
    | 
      
            Lines 149-162
          Returns undef if there are no more objects to return.
      
      
        Link Here
      
     | 
  
        
          | 149 | 
          sub next { | 
          153 | 
          sub next { | 
        
        
          | 150 | 
              my ( $self ) = @_;  | 
          154 | 
              my ( $self ) = @_;  | 
        
        
          | 151 | 
           | 
          155 | 
           | 
        
          
            
              | 152 | 
                  my $result = $self->_resultset()->next();  | 
              156 | 
                  my $object = $self->_objects()->[ $self->{_iterator}++ ]; | 
            
            
              | 153 | 
                  return unless $result;  | 
               | 
               | 
            
        
          | 154 | 
           | 
          157 | 
           | 
        
          
            
              | 155 | 
                  my $object = $self->object_class()->_new_from_dbic( $result );  | 
              158 | 
                  $self->reset() unless $object;  | 
            
        
          | 156 | 
           | 
          159 | 
           | 
        
        
          | 157 | 
              return $object;  | 
          160 | 
              return $object;  | 
        
        
          | 158 | 
          }  | 
          161 | 
          }  | 
        
        
          | 159 | 
           | 
          162 | 
           | 
        
            
               | 
               | 
              163 | 
              =head3 Koha::Objects->first();  | 
            
            
              | 164 | 
               | 
            
            
              | 165 | 
              my $object = Koha::Objects->first();  | 
            
            
              | 166 | 
               | 
            
            
              | 167 | 
              Returns the first object that is part of this set.  | 
            
            
              | 168 | 
               | 
            
            
              | 169 | 
              =cut  | 
            
            
              | 170 | 
               | 
            
            
              | 171 | 
              sub first { | 
            
            
              | 172 | 
                  my ( $self ) = @_;  | 
            
            
              | 173 | 
               | 
            
            
              | 174 | 
                  return $self->_objects()->[0];  | 
            
            
              | 175 | 
              }  | 
            
            
              | 176 | 
               | 
            
        
          | 160 | 
          =head3 Koha::Objects->reset();  | 
          177 | 
          =head3 Koha::Objects->reset();  | 
        
        
          | 161 | 
           | 
          178 | 
           | 
        
        
          | 162 | 
          Koha::Objects->reset();  | 
          179 | 
          Koha::Objects->reset();  | 
        
  
    | 
      
            Lines 169-175
          with the first object in a set.
      
      
        Link Here
      
     | 
  
        
          | 169 | 
          sub reset { | 
          186 | 
          sub reset { | 
        
        
          | 170 | 
              my ( $self ) = @_;  | 
          187 | 
              my ( $self ) = @_;  | 
        
        
          | 171 | 
           | 
          188 | 
           | 
        
          
            
              | 172 | 
                  $self->_resultset()->reset();  | 
              189 | 
                  $self->{_iterator} = 0; | 
            
        
          | 173 | 
           | 
          190 | 
           | 
        
        
          | 174 | 
              return $self;  | 
          191 | 
              return $self;  | 
        
        
          | 175 | 
          }  | 
          192 | 
          }  | 
        
  
    | 
      
            Lines 185-195
          Returns an arrayref of the objects in this set.
      
      
        Link Here
      
     | 
  
        
          | 185 | 
          sub as_list { | 
          202 | 
          sub as_list { | 
        
        
          | 186 | 
              my ( $self ) = @_;  | 
          203 | 
              my ( $self ) = @_;  | 
        
        
          | 187 | 
           | 
          204 | 
           | 
        
          
            
              | 188 | 
                  my @dbic_rows = $self->_resultset()->all();  | 
              205 | 
                  my $objects = $self->_objects();  | 
            
            
               | 
               | 
              206 | 
               | 
            
            
              | 207 | 
                  return wantarray ? @$objects : $objects;  | 
            
            
              | 208 | 
              }  | 
            
            
              | 209 | 
               | 
            
            
              | 210 | 
              =head3 Koha::Objects->_objects  | 
            
            
              | 211 | 
               | 
            
            
              | 212 | 
              Returns an arrayref of all the objects that are part of this Objects set  | 
            
            
              | 213 | 
               | 
            
            
              | 214 | 
              =cut  | 
            
            
              | 215 | 
               | 
            
            
              | 216 | 
              sub _objects { | 
            
            
              | 217 | 
                  my ( $self ) = @_;  | 
            
        
          | 189 | 
           | 
          218 | 
           | 
        
          
            
              | 190 | 
                  my @objects = $self->_wrap(@dbic_rows);  | 
              219 | 
                  $self->{_objects} ||= $self->_wrap( $self->_resultset()->all() ); | 
            
        
          | 191 | 
           | 
          220 | 
           | 
        
          
            
              | 192 | 
                  return wantarray ? @objects : \@objects;  | 
              221 | 
                  return $self->{_objects}; | 
            
        
          | 193 | 
          }  | 
          222 | 
          }  | 
        
        
          | 194 | 
           | 
          223 | 
           | 
        
        
          | 195 | 
          =head3 Koha::Objects->unblessed  | 
          224 | 
          =head3 Koha::Objects->unblessed  | 
        
  
    | 
      
            Lines 215-221
          sub _wrap {
      
      
        Link Here
      
     | 
  
        
          | 215 | 
           | 
          244 | 
           | 
        
        
          | 216 | 
              my @objects = map { $self->object_class()->_new_from_dbic( $_ ) } @dbic_rows; | 
          245 | 
              my @objects = map { $self->object_class()->_new_from_dbic( $_ ) } @dbic_rows; | 
        
        
          | 217 | 
           | 
          246 | 
           | 
        
          
            
              | 218 | 
                  return @objects;  | 
              247 | 
                  return wantarray ? @objects : \@objects;;  | 
            
        
          | 219 | 
          }  | 
          248 | 
          }  | 
        
        
          | 220 | 
           | 
          249 | 
           | 
        
        
          | 221 | 
          =head3 Koha::Objects->_resultset  | 
          250 | 
          =head3 Koha::Objects->_resultset  | 
        
            
              | 222 | 
              -   | 
               | 
               |