| 1 | use Renard::Incunabula::Common::Setup; | ||
| 2 | package Intertangle::Jacquard::Actor::Role::Layoutable; | ||
| 3 | # ABSTRACT: A role for actors that can layout their children | ||
| 4 | $Intertangle::Jacquard::Actor::Role::Layoutable::VERSION = '0.001'; | ||
| 5 | use Moo::Role; | ||
| 6 | |||
| 7 | with qw(Intertangle::Jacquard::Actor::Role::Tree::TreeDAGNode::WithChildren); | ||
| 8 | |||
| 9 | has layout => ( | ||
| 10 | is => 'ro', | ||
| 11 | predicate => 1, | ||
| 12 | ); | ||
| 13 | |||
| 14 | after add_child => method( $actor, %options ) { | ||
| 15 | if( $self->has_layout ) { | ||
| 16 | $self->layout->add_actor( $actor, | ||
| 17 | exists $options{layout} ? %{ $options{layout} } : () | ||
| 18 | ); | ||
| 19 | } | ||
| 20 | }; | ||
| 21 | |||
| 22 | 1; | ||
| 23 | |||
| 24 | __END__ | ||
| 25 | |||
| 26 | =pod | ||
| 27 | |||
| 28 | =encoding UTF-8 | ||
| 29 | |||
| 30 | =head1 NAME | ||
| 31 | |||
| 32 | Intertangle::Jacquard::Actor::Role::Layoutable - A role for actors that can layout their children | ||
| 33 | |||
| 34 | =head1 VERSION | ||
| 35 | |||
| 36 | version 0.001 | ||
| 37 | |||
| 38 | =head1 CONSUMES | ||
| 39 | |||
| 40 | =over 4 | ||
| 41 | |||
| 42 | =item * L<Intertangle::Jacquard::Actor::Role::DataPrinter> | ||
| 43 | |||
| 44 | =item * L<Intertangle::Jacquard::Actor::Role::Tree::TreeDAGNode::WithChildren> | ||
| 45 | |||
| 46 | =back | ||
| 47 | |||
| 48 | =head1 ATTRIBUTES | ||
| 49 | |||
| 50 | =head2 layout | ||
| 51 | |||
| 52 | The layout to use for the children actors. | ||
| 53 | |||
| 54 | Predicate: C<has_layout> | ||
| 55 | |||
| 56 | =head1 METHODS | ||
| 57 | |||
| 58 | =head2 has_layout | ||
| 59 | |||
| 60 | Predicate for C<layout> attribute. | ||
| 61 | |||
| 62 | =head1 AUTHOR | ||
| 63 | |||
| 64 | Zakariyya Mughal <zmughal@cpan.org> | ||
| 65 | |||
| 66 | =head1 COPYRIGHT AND LICENSE | ||
| 67 | |||
| 68 | This software is copyright (c) 2017 by Zakariyya Mughal. | ||
| 69 | |||
| 70 | This is free software; you can redistribute it and/or modify it under | ||
| 71 | the same terms as the Perl 5 programming language system itself. | ||
| 72 | |||
| 73 | =cut |