blob: 3ece152439faf9fbfc3ef62a6134912536dc7f17 (
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
package Bread::Board::Declare::Meta::Role::Class;
use Moose::Role;
# ABSTRACT: class metarole for Bread::Board::Declare
use Bread::Board::Service;
use List::MoreUtils qw(any);
=head1 DESCRIPTION
This role adds functionality to the metaclass of L<Bread::Board::Declare>
classes.
=cut
=method get_all_services
Returns all of the services that are associated with attributes in this class.
=cut
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;
|