| 1 | 4 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 4 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 4 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | package DBIx::DR::Util; | ||||||||||
| 6 | |||||||||||
| 7 | 4 | ▶ | use base qw(Exporter); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 4 | our @EXPORT = qw(camelize decamelize); | |||||||||
| 9 | |||||||||||
| 10 | |||||||||||
| 11 | sub camelize($) { | ||||||||||
| 12 | 30 | ▶ | my ($str) = @_; | ||||||||
|
Subroutine
camelize: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 13 | |||||||||||
| 14 | 30 | my ($module, $method) = split /#/, $str; | |||||||||
| 15 | |||||||||||
| 16 | $module = | ||||||||||
| 17 | 67 | join '', map { ucfirst } split /_/, | |||||||||
| 18 | 30 | join '::' => map { ucfirst lc } split /-/ => $module; | |||||||||
| 19 | |||||||||||
| 20 | 30 | $module =~ s/dbix::dr::/DBIx::DR::/i; | |||||||||
| 21 | |||||||||||
| 22 | 30 | return ($module, $method); | |||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | |||||||||||
| 26 | sub decamelize($;$) { | ||||||||||
| 27 | 7 | ▶ | my ($class, $constructor) = @_; | ||||||||
|
Subroutine
decamelize: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||
| 28 | 7 | for ($class) { | |||||||||
| 29 | 7 | s/(?<!^)[A-Z]/_$&/g; | |||||||||
| 30 | 7 | s/::_/::/g; | |||||||||
| 31 | 7 | s/::/-/g; | |||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | 7 | ▶ | return lc $class unless $constructor; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 6 | return lc($class) . "#$constructor"; | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 4 | 1; | |||||||||
| 39 | |||||||||||
| 40 | =head1 NAME | ||||||||||
| 41 | |||||||||||
| 42 | DBIx::DR::Util - some functions for L<DBIx::DR>. | ||||||||||
| 43 | |||||||||||
| 44 | =head1 COPYRIGHT | ||||||||||
| 45 | |||||||||||
| 46 | Copyright (C) 2011 Dmitry E. Oboukhov <unera@debian.org> | ||||||||||
| 47 | Copyright (C) 2011 Roman V. Nikolaev <rshadow@rambler.ru> | ||||||||||
| 48 | |||||||||||
| 49 | This program is free software, you can redistribute it and/or | ||||||||||
| 50 | modify it under the terms of the Artistic License. | ||||||||||
| 51 | |||||||||||
| 52 | =cut | ||||||||||
| 53 | |||||||||||