1 package SQL::Translator::Role::Debug;
3 use Sub::Quote qw(quote_sub);
7 accessor => 'debugging',
8 init_arg => 'debugging',
9 coerce => quote_sub(q{ $_[0] ? 1 : 0 }),
16 my $class = ref $self;
18 return ${"${class}::DEBUG"};
21 around debugging => sub {
22 my ($orig, $self) = (shift, shift);
24 # Emulate horrible Class::Base API
26 my $dbgref = do { no strict 'refs'; \${"${self}::DEBUG"} };
27 $$dbgref = $_[0] if @_;
30 return $self->$orig(@_);
36 return unless $self->debugging;
38 print STDERR '[', (ref $self || $self), '] ', @_, "\n";