Added . support to xmlrpc
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Utils.pm
1 package Catalyst::Utils;
2
3 use strict;
4 use attributes ();
5
6 =head1 NAME
7
8 Catalyst::Utils - The Catalyst Utils
9
10 =head1 SYNOPSIS
11
12 See L<Catalyst>.
13
14 =head1 DESCRIPTION
15
16 =head1 METHODS
17
18 =over 4
19
20 =item attrs($coderef)
21
22 Returns attributes for coderef in a arrayref
23
24 =cut
25
26 sub attrs { attributes::get( $_[0] ) || [] }
27
28 =item prefix($class, $name);
29
30 Returns a prefixed action.
31
32 =cut
33
34 sub prefix {
35     my ( $class, $name ) = @_;
36     my $prefix = &class2prefix($class);
37     $name = "$prefix/$name" if $prefix;
38     return $name;
39 }
40
41 =item class2classprefix($class);
42
43 Returns the classprefix for class.
44
45 =cut
46
47 sub class2classprefix {
48     my $class = shift || '';
49     my $prefix;
50     if ( $class =~ /^(.*::[MVC]|Model|View|Controller)?::.*$/ ) {
51         $prefix = $1;
52     }
53     return $prefix;
54 }
55
56 =item class2prefix($class);
57
58 Returns the prefix for class.
59
60 =cut
61
62 sub class2prefix {
63     my $class = shift || '';
64     my $prefix;
65     if ( $class =~ /^.*::([MVC]|Model|View|Controller)?::(.*)$/ ) {
66         $prefix = lc $2;
67         $prefix =~ s/\:\:/\//g;
68     }
69     return $prefix;
70 }
71
72 =back
73
74 =head1 AUTHOR
75
76 Sebastian Riedel, C<sri@cpan.org>
77
78 =head1 COPYRIGHT
79
80 This program is free software, you can redistribute it and/or modify it under
81 the same terms as Perl itself.
82
83 =cut
84
85 1;