Markdent/Role/EventsAsMethods.pm

filter: Statementstmt 100% 22 / 22 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 100% 29 / 29 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Markdent/Role/EventAsText.pm ↑ Summary Markdent/Role/Handler.pm »
1 package Markdent::Role::EventsAsMethods;
2  
3 35 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 35 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 35 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 35 our $VERSION = '0.39';
8  
9 35 ▶use Scalar::Util qw( blessed );
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 35 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 35 with 'Markdent::Role::Handler';
14  
15 sub handle_event {
16 5469 ▶ my $self = shift;
Subroutine handle_event: called CC=1 SCAR=0.0
Pod documented
17 5469 my $event = shift;
18  
19 5469 my $meth = $event->event_name;
20  
21 5469 $self->$meth( $event->kv_pairs_for_attributes );
22 }
23  
24 35 1;
25  
26 # ABSTRACT: Turns events into method calls
27  
28 __END__
29  
30 =pod
31  
32 =encoding UTF-8
33  
34 =head1 NAME
35  
36 Markdent::Role::EventsAsMethods - Turns events into method calls
37  
38 =head1 VERSION
39  
40 version 0.39
41  
42 =head1 DESCRIPTION
43  
44 This role takes an object which does L<Markdent::Role::Event> role and turns
45 it into a method call.
46  
47 =head1 METHODS
48  
49 This role provides the following methods:
50  
51 =head2 $object->handle_event($event)
52  
53 Given an object which does L<Markdent::Role::Event> role, this method makes a
54 method call on C<$object> based on the event's name.
55  
56 The method name is the same as the value of C<< $event->event_name >>. The
57 hash reference returned by C<< $event->attributes >> is turned into a set of
58 named parameters for the method. However, any keys starting with "!" in the
59 attributes will not be passed to the method.
60  
61 So, for example, a L<Markdent::Event::StartLink> event turns into a method
62 call like this:
63  
64 $handler->start_link(
65 uri => $event->uri,
66 title => $title, # optional
67 id => $id, # optional
68 is_implicit_id => $event->is_implicit_id,
69 );
70  
71 =head1 ROLES
72  
73 This role does the L<Markdent::Role::Handler> role.
74  
75 =head1 BUGS
76  
77 See L<Markdent> for bug reporting details.
78  
79 Bugs may be submitted at L<https://github.com/houseabsolute/Markdent/issues>.
80  
81 I am also usually active on IRC as 'autarch' on C<irc://irc.perl.org>.
82  
83 =head1 SOURCE
84  
85 The source code repository for Markdent can be found at L<https://github.com/houseabsolute/Markdent>.
86  
87 =head1 AUTHOR
88  
89 Dave Rolsky <autarch@urth.org>
90  
91 =head1 COPYRIGHT AND LICENSE
92  
93 This software is copyright (c) 2021 by Dave Rolsky.
94  
95 This is free software; you can redistribute it and/or modify it under
96 the same terms as the Perl 5 programming language system itself.
97  
98 The full text of the license can be found in the
99 F<LICENSE> file included with this distribution.
100  
101 =cut
« Markdent/Role/EventAsText.pm ↑ Summary Markdent/Role/Handler.pm »