| 1 | #!perl | ||||||||||
| 2 | # vim: softtabstop=4 tabstop=4 shiftwidth=4 ft=perl expandtab smarttab | ||||||||||
| 3 | # PODNAME: RT::Client::REST::Attachment | ||||||||||
| 4 | # ABSTRACT: attachment object representation. | ||||||||||
| 5 | |||||||||||
| 6 | 6 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 6 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | package RT::Client::REST::Attachment; | ||||||||||
| 10 | 6 | $RT::Client::REST::Attachment::VERSION = '0.73'; | |||||||||
| 11 | 6 | ▶ | use parent 'RT::Client::REST::Object'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 6 | ▶ | use Params::Validate qw(:types); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 6 | ▶ | use RT::Client::REST::Object::Exception; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | |||||||||||
| 16 | 6 | ▶ | sub _attributes {{ | ||||||||
|
Subroutine
_attributes: called CC=1 SCAR=0.0
| |||||||||||
| 17 | 6 | id => { | |||||||||
| 18 | validation => { | ||||||||||
| 19 | type => SCALAR, | ||||||||||
| 20 | regex => qr/^\d+$/, | ||||||||||
| 21 | }, | ||||||||||
| 22 | }, | ||||||||||
| 23 | |||||||||||
| 24 | creator_id => { | ||||||||||
| 25 | validation => { | ||||||||||
| 26 | type => SCALAR, | ||||||||||
| 27 | regex => qr/^\d+$/, | ||||||||||
| 28 | }, | ||||||||||
| 29 | rest_name => 'Creator', | ||||||||||
| 30 | }, | ||||||||||
| 31 | |||||||||||
| 32 | parent_id => { | ||||||||||
| 33 | validation => { | ||||||||||
| 34 | type => SCALAR, | ||||||||||
| 35 | regex => qr/^\d+$/, | ||||||||||
| 36 | }, | ||||||||||
| 37 | }, | ||||||||||
| 38 | |||||||||||
| 39 | subject => { | ||||||||||
| 40 | validation => { | ||||||||||
| 41 | type => SCALAR, | ||||||||||
| 42 | }, | ||||||||||
| 43 | }, | ||||||||||
| 44 | |||||||||||
| 45 | content_type => { | ||||||||||
| 46 | validation => { | ||||||||||
| 47 | type => SCALAR, | ||||||||||
| 48 | }, | ||||||||||
| 49 | rest_name => 'ContentType', | ||||||||||
| 50 | }, | ||||||||||
| 51 | |||||||||||
| 52 | file_name => { | ||||||||||
| 53 | validation => { | ||||||||||
| 54 | type => SCALAR, | ||||||||||
| 55 | }, | ||||||||||
| 56 | rest_name => 'Filename', | ||||||||||
| 57 | }, | ||||||||||
| 58 | |||||||||||
| 59 | transaction_id => { | ||||||||||
| 60 | validation => { | ||||||||||
| 61 | type => SCALAR, | ||||||||||
| 62 | regex => qr/^\d+$/, | ||||||||||
| 63 | }, | ||||||||||
| 64 | rest_name => 'Transaction', | ||||||||||
| 65 | }, | ||||||||||
| 66 | |||||||||||
| 67 | message_id => { | ||||||||||
| 68 | validation => { | ||||||||||
| 69 | type => SCALAR, | ||||||||||
| 70 | }, | ||||||||||
| 71 | rest_name => 'MessageId', | ||||||||||
| 72 | }, | ||||||||||
| 73 | |||||||||||
| 74 | created => { | ||||||||||
| 75 | validation => { | ||||||||||
| 76 | type => SCALAR, | ||||||||||
| 77 | }, | ||||||||||
| 78 | is_datetime => 1, | ||||||||||
| 79 | }, | ||||||||||
| 80 | |||||||||||
| 81 | content => { | ||||||||||
| 82 | validation => { | ||||||||||
| 83 | type => SCALAR, | ||||||||||
| 84 | }, | ||||||||||
| 85 | }, | ||||||||||
| 86 | |||||||||||
| 87 | headers => { | ||||||||||
| 88 | validation => { | ||||||||||
| 89 | type => SCALAR, | ||||||||||
| 90 | }, | ||||||||||
| 91 | }, | ||||||||||
| 92 | |||||||||||
| 93 | parent => { | ||||||||||
| 94 | validation => { | ||||||||||
| 95 | type => SCALAR, | ||||||||||
| 96 | }, | ||||||||||
| 97 | }, | ||||||||||
| 98 | |||||||||||
| 99 | content_encoding => { | ||||||||||
| 100 | validation => { | ||||||||||
| 101 | type => SCALAR, | ||||||||||
| 102 | }, | ||||||||||
| 103 | rest_name => 'ContentEncoding', | ||||||||||
| 104 | }, | ||||||||||
| 105 | }} | ||||||||||
| 106 | |||||||||||
| 107 | 1 | ▶ | sub rt_type { 'attachment' } | ||||||||
|
Subroutine
rt_type: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 108 | |||||||||||
| 109 | 0 | ▶ | sub retrieve { | ||||||||
|
Subroutine
retrieve: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 110 | 0 | my $self = shift; | |||||||||
| 111 | |||||||||||
| 112 | 0 | $self->from_form( | |||||||||
| 113 | $self->rt->get_attachment( | ||||||||||
| 114 | parent_id => $self->parent_id, | ||||||||||
| 115 | id => $self->id, | ||||||||||
| 116 | ), | ||||||||||
| 117 | ); | ||||||||||
| 118 | |||||||||||
| 119 | 0 | $self->{__dirty} = {}; | |||||||||
| 120 | |||||||||||
| 121 | 0 | return $self; | |||||||||
| 122 | } | ||||||||||
| 123 | |||||||||||
| 124 | 6 | my @unsupported = qw(store search count); | |||||||||
| 125 | # Override unsupported methods. | ||||||||||
| 126 | 6 | for my $method (@unsupported) { | |||||||||
| 127 | 6 | ▶ | no strict 'refs'; ## no critic (ProhibitNoStrict) | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 128 | 6 | ▶ | *$method = sub { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 129 | 6 | my $self = shift; | |||||||||
| 130 | 6 | RT::Client::REST::Object::IllegalMethodException->throw( | |||||||||
| 131 | ref($self) . " does not support '$method' method", | ||||||||||
| 132 | ); | ||||||||||
| 133 | 18 | }; | |||||||||
| 134 | } | ||||||||||
| 135 | |||||||||||
| 136 | # FIXME this is kind of horrible, probably functions should be provided via mixin? | ||||||||||
| 137 | 17 | ▶ | sub can { | ||||||||
|
Subroutine
can: called CC=2 SCAR=7.4
Pod
documented
| |||||||||||
| 138 | 17 | my ($self, $method) = @_; | |||||||||
| 139 | 17 | ▶ | if (grep { $_ eq $method } @unsupported) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 140 | 0 | return; | |||||||||
| 141 | } | ||||||||||
| 142 | 17 | return $self->SUPER::can($method); | |||||||||
| 143 | } | ||||||||||
| 144 | |||||||||||
| 145 | 6 | __PACKAGE__->_generate_methods; | |||||||||
| 146 | |||||||||||
| 147 | 6 | 1; | |||||||||
| 148 | |||||||||||
| 149 | __END__ | ||||||||||