Guest User

Untitled

a guest
May 20th, 2018
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. package DBIx::Skinny::Mixin::CustomProfiler;
  2. use strict;
  3. use warnings;
  4. our $VERSION = '0.01';
  5.  
  6. use Carp ( );
  7.  
  8.  
  9. sub register_method
  10. {
  11. return {
  12. register_profiler => \&register_profiler,
  13. };
  14. }
  15.  
  16.  
  17. sub register_profiler
  18. {
  19. my $class = shift;
  20. my ($profiler, $config, $profile) = @_;
  21.  
  22. eval "use $profiler"; ## no critic
  23. Carp::croak $@ if $@;
  24.  
  25. unless ( $profiler->can('record_query') ) {
  26. Carp::croak "profiler must implement a 'record_query' method";
  27. }
  28.  
  29. $class->attribute->{profile} = $profile || 0;
  30. $class->attribute->{profiler} = $profiler->new($config);
  31. }
  32.  
  33.  
  34. 1;
Add Comment
Please, Sign In to add comment