From: Moritz Bunkus Date: Wed, 29 Jan 2014 14:34:00 +0000 (+0100) Subject: L-Plugin: Hilfsfunktion is_rdbo($obj) zum Testen ob $obj von einem RDBO ableitet X-Git-Tag: release-3.2.0beta~491^2~31 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=54fc0d08dd13e66c5e87c49dc424cc3bd26476f5;p=kivitendo-erp.git L-Plugin: Hilfsfunktion is_rdbo($obj) zum Testen ob $obj von einem RDBO ableitet --- diff --git a/SL/Template/Plugin/LxERP.pm b/SL/Template/Plugin/LxERP.pm index 40bf195f2..f935a5910 100644 --- a/SL/Template/Plugin/LxERP.pm +++ b/SL/Template/Plugin/LxERP.pm @@ -1,6 +1,7 @@ package SL::Template::Plugin::LxERP; use base qw( Template::Plugin ); +use Scalar::Util qw(); use Template::Plugin; use List::Util qw(min); @@ -16,6 +17,16 @@ sub new { bless { }, $class; } +sub is_rdbo { + my ($self, $obj, $wanted_class) = @_; + + $wanted_class = !$wanted_class ? 'Rose::DB::Object' + : $wanted_class =~ m{::} ? $wanted_class + : "SL::DB::${wanted_class}"; + + return Scalar::Util::blessed($obj) ? $obj->isa($wanted_class) : 0; +} + sub format_amount { my ($self, $var, $places, $skip_zero, $dash) = @_;