From 54fc0d08dd13e66c5e87c49dc424cc3bd26476f5 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 29 Jan 2014 15:34:00 +0100 Subject: [PATCH] L-Plugin: Hilfsfunktion is_rdbo($obj) zum Testen ob $obj von einem RDBO ableitet --- SL/Template/Plugin/LxERP.pm | 11 +++++++++++ 1 file changed, 11 insertions(+) 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) = @_; -- 2.20.1