summaryrefslogtreecommitdiffstats
path: root/lib/Bread/Board/Declare/Meta/Role/Class.pm
blob: 2869f7e4abb4fe555f5041d5611d03c58034553e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package Bread::Board::Declare::Meta::Role::Class;
use Moose::Role;

use Bread::Board::Service;
use List::MoreUtils qw(any);

sub get_all_services {
    my $self = shift;
    return map { $_->associated_service }
           grep { $_->has_associated_service }
           grep { Moose::Util::does_role($_, 'Bread::Board::Declare::Meta::Role::Attribute') }
           $self->get_all_attributes;
}

before superclasses => sub {
    my $self = shift;

    return unless @_;

    die "Multiple inheritance is not supported for Bread::Board::Declare classes"
        if @_ > 1;

    return if $_[0]->isa('Bread::Board::Container');

    die "Cannot inherit from " . join(', ', @_)
      . " because Bread::Board::Declare classes must inherit"
      . " from Bread::Board::Container";
};

no Moose::Role;

1;