This file is indexed.

/usr/share/perl5/Magpie/Resource.pm is in libmagpie-perl 1.141660-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
package Magpie::Resource;
$Magpie::Resource::VERSION = '1.141660';
# ABSTRACT: Abstract base class for all resource types;

use Moose;
extends 'Magpie::Component';
with 'Magpie::Dispatcher::RequestMethod';
use Magpie::Constants;

__PACKAGE__->register_events(Magpie::Dispatcher::RequestMethod::events());

has '+_trait_namespace' => ( default => 'Magpie::Plugin::Resource' );

has produces => (
    is       => 'ro',
    isa      => 'Str',
    required => 1,
    default  => 'text/plain',
);

has consumes => (
    is       => 'ro',
    isa      => 'Str',
    required => 1,
    default  => 'text/plain',
);

has data => (
    is        => 'rw',
    predicate => 'has_data',
    clearer   => 'clear_data',
);

has state => (
    is       => 'rw',
    isa      => 'Str',
    default  => 'uninitialized',
    required => 1,
);

has dependencies => (
    traits  => ['Hash'],
    is      => 'rw',
    isa     => 'HashRef[HashRef]',
    default => sub { {} },
    handles => {
        add_dependency    => 'set',
        get_dependency    => 'get',
        delete_dependency => 'delete',
        has_dependencies  => 'count',
    },
);

sub methods_implemented {
    my $self = shift;
    my %implemented = ();
    foreach my $class ( $self->meta->linearized_isa ) {
        next if $class =~ /^(Magpie|Moose)::/;
        foreach (HTTP_METHODS){
            $implemented{$_}++ if $class->meta->has_method($_);
        }
    }
    return ( keys( %implemented ));
}

sub method_not_allowed {
    my $self = shift;
    my $method = $self->plack_request->method || 'unknown';
    my @allowed = $self->methods_implemented;
    $self->set_error(
        {   status_code        => 405,
            reason             => "Method '$method' not allowed.",
            additional_headers => [ Allow => \@allowed ],
        }
    );
    return DONE;
}

sub GET {
    shift->method_not_allowed(@_);
}

sub POST {
    shift->method_not_allowed(@_);
}

sub PUT {
    shift->method_not_allowed(@_);
}

sub DELETE {
    shift->method_not_allowed(@_);
}

sub HEAD {
    shift->method_not_allowed(@_);
}

sub OPTIONS {
    shift->method_not_allowed(@_);
}

sub TRACE {
    shift->method_not_allowed(@_);
}

sub PATCH {
    shift->method_not_allowed(@_);
}

sub CONNECT {
    shift->method_not_allowed(@_);
}

# convenience for container-based Resources
sub get_entity_id {
    my $self = shift;
    my $path = $self->request->path_info;
    return undef if $path =~ /\/$/;
    my @steps = split '/', $path;
    my $id = $self->request->param('id') || pop @steps;
    return $id;
}

1;



=pod

=head1 NAME

Magpie::Resource - Abstract base class for all resource types;

=head1 VERSION

version 1.141660

=head1 DESCRIPTION

   A resource is not the thing that is transferred across the wire or picked
   up off the disk or seen from afar while walking your dog. Each of those is
   only a representation. The same is true of physical objects encountered in
   life and never identified with URI and never made accessible on the net.
   Yes, it does present a bit of a quandary, but it is one that we have all
   learned to live with. Our eyes are not powerful enough to see identity
   through the representations, but our minds are powerful enough to associate
   identity to that which we see. Do I think of a different identifier every
   time I see my dog, or do I simply think of my dog as one identity and
   experience many representations of that identity over time (and on into
   memory and imagination)?

   Roy Fielding - July 2002

=head1 AUTHORS

=over 4

=item *

Kip Hampton <kip.hampton@tamarou.com>

=item *

Chris Prather <chris.prather@tamarou.com>

=back

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2011 by Tamarou, LLC.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=head1 SEE ALSO

=over 4

=item *

L<Magpie>

=back

=cut


__END__