line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Markdent::Role::EventsAsMethods; |
2
|
|
|
|
|
|
|
|
3
|
35
|
|
|
35
|
|
26462
|
use strict; |
|
35
|
|
|
|
|
106
|
|
|
35
|
|
|
|
|
1175
|
|
4
|
35
|
|
|
35
|
|
201
|
use warnings; |
|
35
|
|
|
|
|
78
|
|
|
35
|
|
|
|
|
1123
|
|
5
|
35
|
|
|
35
|
|
197
|
use namespace::autoclean; |
|
35
|
|
|
|
|
101
|
|
|
35
|
|
|
|
|
272
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.39'; |
8
|
|
|
|
|
|
|
|
9
|
35
|
|
|
35
|
|
3454
|
use Scalar::Util qw( blessed ); |
|
35
|
|
|
|
|
76
|
|
|
35
|
|
|
|
|
2211
|
|
10
|
|
|
|
|
|
|
|
11
|
35
|
|
|
35
|
|
256
|
use Moose::Role; |
|
35
|
|
|
|
|
79
|
|
|
35
|
|
|
|
|
523
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
with 'Markdent::Role::Handler'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub handle_event { |
16
|
5469
|
|
|
5469
|
1
|
30547
|
my $self = shift; |
17
|
5469
|
|
|
|
|
7370
|
my $event = shift; |
18
|
|
|
|
|
|
|
|
19
|
5469
|
|
|
|
|
16712
|
my $meth = $event->event_name; |
20
|
|
|
|
|
|
|
|
21
|
5469
|
|
|
|
|
15508
|
$self->$meth( $event->kv_pairs_for_attributes ); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
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 |