line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Markdent::Role::EventsAsMethods; |
2
|
|
|
|
|
|
|
|
3
|
34
|
|
|
34
|
|
23332
|
use strict; |
|
34
|
|
|
|
|
94
|
|
|
34
|
|
|
|
|
1140
|
|
4
|
34
|
|
|
34
|
|
207
|
use warnings; |
|
34
|
|
|
|
|
96
|
|
|
34
|
|
|
|
|
1025
|
|
5
|
34
|
|
|
34
|
|
211
|
use namespace::autoclean; |
|
34
|
|
|
|
|
101
|
|
|
34
|
|
|
|
|
251
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.38'; |
8
|
|
|
|
|
|
|
|
9
|
34
|
|
|
34
|
|
3272
|
use Scalar::Util qw( blessed ); |
|
34
|
|
|
|
|
90
|
|
|
34
|
|
|
|
|
1997
|
|
10
|
|
|
|
|
|
|
|
11
|
34
|
|
|
34
|
|
250
|
use Moose::Role; |
|
34
|
|
|
|
|
105
|
|
|
34
|
|
|
|
|
453
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
with 'Markdent::Role::Handler'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub handle_event { |
16
|
5450
|
|
|
5450
|
1
|
30801
|
my $self = shift; |
17
|
5450
|
|
|
|
|
7995
|
my $event = shift; |
18
|
|
|
|
|
|
|
|
19
|
5450
|
|
|
|
|
16854
|
my $meth = $event->event_name(); |
20
|
|
|
|
|
|
|
|
21
|
5450
|
|
|
|
|
15593
|
$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.38 |
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) 2020 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 |