Created
July 5, 2016 13:32
-
-
Save akzhan/93113ff2a6d8420c7ff6b4bcd023085c to your computer and use it in GitHub Desktop.
HashRefInflator that knows about utf8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package BUX::DB::HashRefInflator; | |
use strict; | |
use warnings; | |
use utf8; | |
use parent qw( DBIx::Class::ResultClass::HashRefInflator ); | |
sub inflate_result { | |
my ( $self, @args ) = @_; | |
my $res = $self->SUPER::inflate_result( @args ); | |
$res = { | |
map { | |
my $val = $res->{$_}; | |
utf8::decode($val) if defined $val && !ref($val); | |
( $_ => $val ); | |
} keys %$res | |
} if ref($res) eq 'HASH'; | |
return $res; | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment