| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Venus::Role::Patchable; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 96 |  |  | 96 |  | 1814 | use 5.018; | 
|  | 96 |  |  |  |  | 354 |  | 
| 4 |  |  |  |  |  |  |  | 
| 5 | 96 |  |  | 96 |  | 544 | use strict; | 
|  | 96 |  |  |  |  | 226 |  | 
|  | 96 |  |  |  |  | 1991 |  | 
| 6 | 96 |  |  | 96 |  | 474 | use warnings; | 
|  | 96 |  |  |  |  | 221 |  | 
|  | 96 |  |  |  |  | 2889 |  | 
| 7 |  |  |  |  |  |  |  | 
| 8 | 96 |  |  | 96 |  | 602 | use Venus::Role 'with'; | 
|  | 96 |  |  |  |  | 218 |  | 
|  | 96 |  |  |  |  | 655 |  | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | # METHODS | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | sub patch { | 
| 13 | 2 |  |  | 2 | 1 | 85 | my ($self, $name, $code) = @_; | 
| 14 |  |  |  |  |  |  |  | 
| 15 | 2 |  |  |  |  | 12 | require Venus::Space; | 
| 16 |  |  |  |  |  |  |  | 
| 17 | 2 |  | 66 |  |  | 38 | my $space = Venus::Space->new(ref $self || $self); | 
| 18 |  |  |  |  |  |  |  | 
| 19 | 2 |  |  |  |  | 26 | return $space->patch($name, $code); | 
| 20 |  |  |  |  |  |  | } | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | # EXPORTS | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  | sub EXPORT { | 
| 25 | 98 |  |  | 98 | 0 | 402 | ['patch'] | 
| 26 |  |  |  |  |  |  | } | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | 1; | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  |  | 
| 32 |  |  |  |  |  |  | =head1 NAME | 
| 33 |  |  |  |  |  |  |  | 
| 34 |  |  |  |  |  |  | Venus::Role::Patchable - Patchable Role | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | =cut | 
| 37 |  |  |  |  |  |  |  | 
| 38 |  |  |  |  |  |  | =head1 ABSTRACT | 
| 39 |  |  |  |  |  |  |  | 
| 40 |  |  |  |  |  |  | Patchable Role for Perl 5 | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | =cut | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 45 |  |  |  |  |  |  |  | 
| 46 |  |  |  |  |  |  | package Example; | 
| 47 |  |  |  |  |  |  |  | 
| 48 |  |  |  |  |  |  | use Venus::Class; | 
| 49 |  |  |  |  |  |  |  | 
| 50 |  |  |  |  |  |  | with 'Venus::Role::Patchable'; | 
| 51 |  |  |  |  |  |  |  | 
| 52 |  |  |  |  |  |  | package main; | 
| 53 |  |  |  |  |  |  |  | 
| 54 |  |  |  |  |  |  | my $example = Example->new; | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  | # my $patch = $example->patch; | 
| 57 |  |  |  |  |  |  |  | 
| 58 |  |  |  |  |  |  | # bless(.., "Venus::Space") | 
| 59 |  |  |  |  |  |  |  | 
| 60 |  |  |  |  |  |  | =cut | 
| 61 |  |  |  |  |  |  |  | 
| 62 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 63 |  |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  | This package modifies the consuming package and provides methods for patching | 
| 65 |  |  |  |  |  |  | (or monkey-patching) routines in the calling package using | 
| 66 |  |  |  |  |  |  | L. | 
| 67 |  |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  | =cut | 
| 69 |  |  |  |  |  |  |  | 
| 70 |  |  |  |  |  |  | =head1 METHODS | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  | This package provides the following methods: | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | =cut | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  | =head2 patch | 
| 77 |  |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  | patch(string $name, coderef $code) (Venus::Space) | 
| 79 |  |  |  |  |  |  |  | 
| 80 |  |  |  |  |  |  | The patch method overwrites the named subroutine in the calling package using | 
| 81 |  |  |  |  |  |  | L returning a L object that can be used to | 
| 82 |  |  |  |  |  |  | restore the original subroutine when L is called. | 
| 83 |  |  |  |  |  |  |  | 
| 84 |  |  |  |  |  |  | I> | 
| 85 |  |  |  |  |  |  |  | 
| 86 |  |  |  |  |  |  | =over 4 | 
| 87 |  |  |  |  |  |  |  | 
| 88 |  |  |  |  |  |  | =item patch example 1 | 
| 89 |  |  |  |  |  |  |  | 
| 90 |  |  |  |  |  |  | package Example; | 
| 91 |  |  |  |  |  |  |  | 
| 92 |  |  |  |  |  |  | use Venus::Class; | 
| 93 |  |  |  |  |  |  |  | 
| 94 |  |  |  |  |  |  | with 'Venus::Role::Patchable'; | 
| 95 |  |  |  |  |  |  |  | 
| 96 |  |  |  |  |  |  | sub test { | 
| 97 |  |  |  |  |  |  | my ($self, @args) = @_; | 
| 98 |  |  |  |  |  |  |  | 
| 99 |  |  |  |  |  |  | return [$self, @args]; | 
| 100 |  |  |  |  |  |  | } | 
| 101 |  |  |  |  |  |  |  | 
| 102 |  |  |  |  |  |  | package main; | 
| 103 |  |  |  |  |  |  |  | 
| 104 |  |  |  |  |  |  | my $example = Example->new; | 
| 105 |  |  |  |  |  |  |  | 
| 106 |  |  |  |  |  |  | my $patch = $example->patch('test', sub { | 
| 107 |  |  |  |  |  |  | my ($next, @args) = @_; | 
| 108 |  |  |  |  |  |  |  | 
| 109 |  |  |  |  |  |  | return ['patched', @{$next->(@args)}]; | 
| 110 |  |  |  |  |  |  | }); | 
| 111 |  |  |  |  |  |  |  | 
| 112 |  |  |  |  |  |  | # bless(.., "Venus::Space") | 
| 113 |  |  |  |  |  |  |  | 
| 114 |  |  |  |  |  |  | =back | 
| 115 |  |  |  |  |  |  |  | 
| 116 |  |  |  |  |  |  | =cut | 
| 117 |  |  |  |  |  |  |  | 
| 118 |  |  |  |  |  |  | =head1 AUTHORS | 
| 119 |  |  |  |  |  |  |  | 
| 120 |  |  |  |  |  |  | Awncorp, C | 
| 121 |  |  |  |  |  |  |  | 
| 122 |  |  |  |  |  |  | =cut | 
| 123 |  |  |  |  |  |  |  | 
| 124 |  |  |  |  |  |  | =head1 LICENSE | 
| 125 |  |  |  |  |  |  |  | 
| 126 |  |  |  |  |  |  | Copyright (C) 2000, Awncorp, C. | 
| 127 |  |  |  |  |  |  |  | 
| 128 |  |  |  |  |  |  | This program is free software, you can redistribute it and/or modify it under | 
| 129 |  |  |  |  |  |  | the terms of the Apache license version 2.0. | 
| 130 |  |  |  |  |  |  |  | 
| 131 |  |  |  |  |  |  | =cut |