1 package Catalyst::Controller::DBIC::API::JoinBuilder;
3 #ABSTRACT: Provides a helper class to automatically keep track of joins in complex searches
5 use MooseX::Types::Moose(':all');
6 use Catalyst::Controller::DBIC::API::Types(':all');
7 use namespace::autoclean;
9 =attribute_public parent is: ro, isa: 'Catalyst::Controller::DBIC::API::JoinBuilder'
11 parent stores the direct ascendant in the datastructure that represents the join
19 predicate => 'has_parent',
21 trigger => sub { my ($self, $new) = @_; $new->add_child($self); },
24 =attribute_public children is: ro, isa: ArrayRef['Catalyst::Controller::DBIC::API::JoinBuilder'], traits => ['Array']
26 children stores the immediate descendants in the datastructure that represents the join.
28 Handles the following methods:
30 all_children => 'elements'
31 has_children => 'count'
39 isa => ArrayRef[JoinBuilder],
41 default => sub { [] },
44 all_children => 'elements',
45 has_children => 'count',
50 =attribute_public joins is: ro, isa: HashRef, lazy_build: true
52 joins holds the cached generated join datastructure.
63 =attribute_public name is: ro, isa: Str, required: 1
65 Sets the key for this level in the generated hash
76 =method_private _build_joins
78 _build_joins finds the top parent in the structure and then recursively iterates the children building out the join datastructure
87 while(my $found = $self->parent)
89 if($found->has_parent)
102 map { $foo->{$_->name} = $builder->($_) } $node->all_children;
106 return $builder->($parent || $self);
111 JoinBuilder is used to keep track of joins automgically for complex searches. It accomplishes this by building a simple tree of parents and children and then recursively drilling into the tree to produce a useable join attribute for ->search.