This seems to no longer be used anywhere...?
[dbsrgits/SQL-Translator.git] / lib / SQL / Translator / Generator / Role / Quote.pm
CommitLineData
598a2461 1package # hide from pause
2 SQL::Translator::Generator::Role::Quote;
3
d22073f1 4# AUTHOR: Arthur Axel fREW Schmidt
5# Copyright: Same as Perl 5
6
598a2461 7use Moo::Role;
8
9requires qw(quote_chars name_sep);
10
11sub quote {
12 my ($self, $label) = @_;
13
14 return '' unless defined $label;
15 return $$label if ref($label) eq 'SCALAR';
16
17 my @quote_chars = @{$self->quote_chars};
18 return $label unless scalar @quote_chars;
19
20 my ($l, $r);
21 if (@quote_chars == 1) {
22 ($l, $r) = (@quote_chars) x 2;
23 } elsif (@quote_chars == 2) {
24 ($l, $r) = @quote_chars;
25 } else {
26 die 'too many quote chars!';
27 }
28
29 my $sep = $self->name_sep || '';
30 # parts containing * are naturally unquoted
31 join $sep, map "$l$_$r", ( $sep ? split (/\Q$sep\E/, $label ) : $label )
32}
33
341;