| 1 | package Markdent::CapturedEvents; | ||
| 2 | |||
| 3 | 4 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 4 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 4 | ▶ | use namespace::autoclean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 4 | our $VERSION = '0.40'; | |
| 8 | |||
| 9 | 4 | ▶ | use Markdent::Types; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | 4 | ▶ | use Params::ValidationCompiler qw( validation_for ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | 4 | ▶ | use Specio::Declare; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | |||
| 13 | 4 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 14 | 4 | ▶ | use MooseX::StrictConstructor; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | |||
| 16 | has _events => ( | ||
| 17 | is => 'ro', | ||
| 18 | isa => t( 'ArrayRef', of => t('EventObject') ), | ||
| 19 | init_arg => 'events', | ||
| 20 | 1 | ▶ | default => sub { [] }, |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 21 | 4 | ); | |
| 22 | |||
| 23 | sub events { | ||
| 24 | 3 | ▶ | @{ $_[0]->_events }; |
|
Subroutine
events: called CC=1 SCAR=0.0
Pod
documented
| |||
| 25 | } | ||
| 26 | |||
| 27 | { | ||
| 28 | 4 | my $validator = validation_for( | |
| 29 | params => [ { type => t('EventObject') } ], | ||
| 30 | slurpy => t('EventObject'), | ||
| 31 | ); | ||
| 32 | |||
| 33 | sub capture_events { | ||
| 34 | 264 | ▶ | my $self = shift; |
|
Subroutine
capture_events: called CC=1 SCAR=0.0
Pod
documented
| |||
| 35 | 264 | my @events = $validator->(@_); | |
| 36 | |||
| 37 | 264 | push @{ $self->_events }, @events; | |
| 38 | } | ||
| 39 | } | ||
| 40 | |||
| 41 | { | ||
| 42 | 4 | my $validator = validation_for( | |
| 43 | params => [ { type => t('HandlerObject') } ], | ||
| 44 | ); | ||
| 45 | |||
| 46 | sub replay_events { | ||
| 47 | 2 | ▶ | my $self = shift; |
|
Subroutine
replay_events: called CC=2 SCAR=6.9
Pod
documented
| |||
| 48 | 2 | my ($handler) = $validator->(@_); | |
| 49 | |||
| 50 | 2 | $handler->handle_event($_) for $self->events; | |
| 51 | } | ||
| 52 | } | ||
| 53 | |||
| 54 | 4 | __PACKAGE__->meta->make_immutable; | |
| 55 | |||
| 56 | 4 | 1; | |
| 57 | |||
| 58 | # ABSTRACT: Represents a series of captured events | ||
| 59 | |||
| 60 | __END__ | ||
| 61 | |||
| 62 | =pod | ||
| 63 | |||
| 64 | =encoding UTF-8 | ||
| 65 | |||
| 66 | =head1 NAME | ||
| 67 | |||
| 68 | Markdent::CapturedEvents - Represents a series of captured events | ||
| 69 | |||
| 70 | =head1 VERSION | ||
| 71 | |||
| 72 | version 0.40 | ||
| 73 | |||
| 74 | =head1 DESCRIPTION | ||
| 75 | |||
| 76 | This represents a series of captured parser events, and can be used to replay | ||
| 77 | them with a handle. | ||
| 78 | |||
| 79 | =head1 METHODS | ||
| 80 | |||
| 81 | This class provides the following methods: | ||
| 82 | |||
| 83 | =head2 Markdent::CapturedEvents->new( events => \@events ); | ||
| 84 | |||
| 85 | Creates a new Markdent::CapturedEvents object. | ||
| 86 | |||
| 87 | =head2 $captured->events | ||
| 88 | |||
| 89 | Returns the captured events as an array. | ||
| 90 | |||
| 91 | =head2 $captured->capture_events(@events) | ||
| 92 | |||
| 93 | Captures one or more events. | ||
| 94 | |||
| 95 | =head2 $captured->replay_events($handler) | ||
| 96 | |||
| 97 | Given an object which does the L<Markdent::Role::Handler> role, this method | ||
| 98 | will replay all the captured events to that handler. | ||
| 99 | |||
| 100 | =head1 BUGS | ||
| 101 | |||
| 102 | See L<Markdent> for bug reporting details. | ||
| 103 | |||
| 104 | Bugs may be submitted at L<https://github.com/houseabsolute/Markdent/issues>. | ||
| 105 | |||
| 106 | I am also usually active on IRC as 'autarch' on C<irc://irc.perl.org>. | ||
| 107 | |||
| 108 | =head1 SOURCE | ||
| 109 | |||
| 110 | The source code repository for Markdent can be found at L<https://github.com/houseabsolute/Markdent>. | ||
| 111 | |||
| 112 | =head1 AUTHOR | ||
| 113 | |||
| 114 | Dave Rolsky <autarch@urth.org> | ||
| 115 | |||
| 116 | =head1 COPYRIGHT AND LICENSE | ||
| 117 | |||
| 118 | This software is copyright (c) 2021 by Dave Rolsky. | ||
| 119 | |||
| 120 | This is free software; you can redistribute it and/or modify it under | ||
| 121 | the same terms as the Perl 5 programming language system itself. | ||
| 122 | |||
| 123 | The full text of the license can be found in the | ||
| 124 | F<LICENSE> file included with this distribution. | ||
| 125 | |||
| 126 | =cut | ||