File Coverage

blib/lib/Bot/Backbone/Types.pm
Criterion Covered Total %
statement 20 20 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod n/a
total 27 27 100.0


line stmt bran cond sub pod time code
1             package Bot::Backbone::Types;
2             $Bot::Backbone::Types::VERSION = '0.161950';
3 4     4   35 use v5.10;
  4         8  
4 4     4   16 use Moose;
  4         4  
  4         19  
5              
6 4     4   18267 use List::MoreUtils qw( all );
  4         28017  
  4         30  
7 4     4   4298 use MooseX::Types::Moose qw( ArrayRef ClassName CodeRef HashRef Object );
  4         198493  
  4         45  
8 4         23 use MooseX::Types -declare => [ qw(
9             DispatcherType
10             EventLoop
11             PredicateList
12             ServiceList
13             VolumeLevel
14 4     4   14955 ) ];
  4         5  
15 4     4   16282 use Scalar::Util qw( blessed );
  4         6  
  4         259  
16              
17 4     4   18 use namespace::autoclean;
  4         5  
  4         23  
18              
19             # ABSTRACT: The type library for Bot::Backbone
20              
21              
22             class_type 'Moose::Meta::Class';
23             enum DispatcherType, [qw( bot service )];
24             coerce DispatcherType,
25             from 'Moose::Meta::Class',
26             via {
27             if ($_->name->isa('Bot::Backbone::Bot')) { 'bot' }
28             elsif ($_->name->does('Bot::Backbone::Service::Role::Service')) { 'service' }
29             else { die "unknown meta object $_ in DispatherType coercion" }
30             };
31              
32              
33             subtype EventLoop,
34             as ClassName|Object,
35             where { $_->can('run') };
36              
37              
38             role_type 'Bot::Backbone::Dispatcher::Predicate';
39             subtype PredicateList,
40             as ArrayRef,
41             where { all { $_->does('Bot::Backbone::Dispatcher::Predicate') } @$_ };
42              
43              
44             class_type 'Bot::Backbone::Service::Role::Service';
45             subtype ServiceList,
46             as HashRef[Object],
47             where { all { blessed $_ and $_->does('Bot::Backbone::Service::Role::Service') } values %$_ };
48              
49              
50             enum VolumeLevel, [ qw( shout spoken whisper ) ];
51              
52             __PACKAGE__->meta->make_immutable;
53              
54             __END__
55              
56             =pod
57              
58             =encoding UTF-8
59              
60             =head1 NAME
61              
62             Bot::Backbone::Types - The type library for Bot::Backbone
63              
64             =head1 VERSION
65              
66             version 0.161950
67              
68             =head1 DESCRIPTION
69              
70             This is a container for the various types used by L<Bot::Backbone>. It is built
71             using L<MooseX::Types>.
72              
73             =head1 TYPES
74              
75             =head2 DispatcherType
76              
77             This is an enum with the following values:
78              
79             bot
80             service
81              
82             =head2 EventLoop
83              
84             This is just an object with a C<run> method.
85              
86             =head2 PredicateList
87              
88             This is an array of code references.
89              
90             =head2 ServiceList
91              
92             This is a hash of objects that implement L<Bot::Backbone::Service::Role::Service>.
93              
94             =head2 VolumeLevel
95              
96             This is an enumeration of possible volume levels for chats. It must be one of the following:
97              
98             shout
99             spoken
100             whisper
101              
102             =head1 AUTHOR
103              
104             Andrew Sterling Hanenkamp <hanenkamp@cpan.org>
105              
106             =head1 COPYRIGHT AND LICENSE
107              
108             This software is copyright (c) 2016 by Qubling Software LLC.
109              
110             This is free software; you can redistribute it and/or modify it under
111             the same terms as the Perl 5 programming language system itself.
112              
113             =cut