Revision bc3a01ae
Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt
SL/DB/Helper/Mappings.pm | ||
---|---|---|
3 | 3 |
use utf8; |
4 | 4 |
use strict; |
5 | 5 |
|
6 |
use SL::Util qw(camelify); |
|
7 |
|
|
6 | 8 |
require Exporter; |
7 | 9 |
our @ISA = qw(Exporter); |
8 | 10 |
our @EXPORT_OK = qw(get_table_for_package get_package_for_table get_package_names); |
... | ... | |
157 | 159 |
die "Can't resolve '$string' as a database model, sorry. Did you perhaps forgot to load it?"; |
158 | 160 |
} |
159 | 161 |
|
160 |
sub camelify { |
|
161 |
my ($str) = @_; |
|
162 |
$str =~ s/_+(.)/uc($1)/ge; |
|
163 |
ucfirst $str; |
|
164 |
} |
|
165 |
|
|
166 |
sub snakify { |
|
167 |
my ($str) = @_; |
|
168 |
$str =~ s/(?<!^)\u(.)/'_' . lc($1)/ge; |
|
169 |
lcfirst $str; |
|
170 |
} |
|
171 |
|
|
172 | 162 |
sub plurify { |
173 | 163 |
my ($str) = @_; |
174 | 164 |
$str . 's'; |
Auch abrufbar als: Unified diff
Funktionen 'snakify' und 'camelify' nach SL::Util verschoben, gebugfixt, getestet