indexed by
[dbsrgits/DBIx-Data-Store-old.git] / lib / DBIx / Data / Collection / Set / IndexableBy.pm
index 63e4901..dd90193 100644 (file)
@@ -16,9 +16,17 @@ method indexed_by ($by) {
   my $index_spec = $self->_indexable_by->{$by};
   die "${self} not indexable by ${by}" unless $index_spec;
   my $new = DBIx::Data::Collection::Set->new($index_spec);
+  $self->_connect_caches($new);
   $self->_indexed_by->{$by} = $new
 }
 
+method _connect_caches ($new) {
+  $new->_set_member_cache($self->_member_cache) if $self->_member_cache_built;
+  $new->_add_to_caches($_) for $self->_all_key_cache_members;
+  $new->_setup_observation_of($self);
+  $self->_setup_observation_of($new);
+}
+
 __PACKAGE__->meta->make_immutable;
 
 1;