From fedd67a7f625e672c709a16db89c6de2cd5ab6b4 Mon Sep 17 00:00:00 2001 From: Isaac Date: Sun, 21 Jan 2018 21:11:05 +0100 Subject: [PATCH] add to_string --- scripts/ZoneMinder/lib/ZoneMinder/Object.pm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Object.pm b/scripts/ZoneMinder/lib/ZoneMinder/Object.pm index df7118f0f..e0dcef4d3 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Object.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Object.pm @@ -430,6 +430,13 @@ sub transform { return $value; } # end sub transform + +sub to_string { + my $type = ref($_[0]); + my $fields = eval '\%'.$type.'::fields'; + return $type . ': '. join(' ' , map { $_[0]{$_} ? "$_ => $_[0]{$_}" : () } keys %$fields ); +} + 1; __END__