From 89596089e88499a2ce217b9d4cc2e60119d1798b Mon Sep 17 00:00:00 2001 From: "renater.salaun" <renater.salaun@047e039d-479c-447e-8a29-aa6bf4a09bab> Date: Fri, 12 Dec 2014 14:42:58 +0000 Subject: [PATCH] Now inheriting from IdPAccountManager::Data::Serviceprovider git-svn-id: https://svn.geant.net/GEANT/edugain_testidp_account_manager/trunk@74 047e039d-479c-447e-8a29-aa6bf4a09bab --- lib/IdPAccountManager/ServiceProvider.pm | 55 +----------------------- 1 file changed, 2 insertions(+), 53 deletions(-) diff --git a/lib/IdPAccountManager/ServiceProvider.pm b/lib/IdPAccountManager/ServiceProvider.pm index 748f627..d744746 100644 --- a/lib/IdPAccountManager/ServiceProvider.pm +++ b/lib/IdPAccountManager/ServiceProvider.pm @@ -1,4 +1,5 @@ package IdPAccountManager::ServiceProvider; +use parent 'IdPAccountManager::Data::Serviceprovider'; use strict; @@ -14,63 +15,11 @@ my @EXPORT = qw(); use Carp; -INIT { +INIT { ## Set error mode to non fatal IdPAccountManager::Data::Serviceprovider::Manager->error_mode('return'); } -sub new { - my ($pkg) = shift; - my %args = @_; - - my $self = {}; - - ## Bless ServiceProvider object - bless $self, $pkg; - - ## Object may be created either with a hashref as argument or an IdPAccountManager::Data::Serviceprovider object - ## Second case is usefull when fetching a set of IdPAccountManager::Data::Serviceprovider via IdPAccountManager::Data::Serviceprovider::Manager - if (ref($_[0]) eq 'IdPAccountManager::Data::Serviceprovider') { - $self->{'persistent'} = $_[0]; - }else { - $self->{'persistent'} = IdPAccountManager::Data::Serviceprovider->new(%args); - } - - return $self; -} - -sub load { - my $self = shift; - my %args = @_; - - return $self->{'persistent'}->load(%args); -} - -sub get { - my $self = shift; - my $attribute_name = shift; - - return $self->{'persistent'}->$attribute_name; -} - -sub save { - my $self = shift; - - unless ($self->{'persistent'}->save()) { - IdPAccountManager::Tools::do_log('error', "Failed to save Serviceprovider in DB"); - return undef; - } -} - -## Delete a test account -sub delete { - my $self = shift; - - unless ($self->{'persistent'}->delete()) { - IdPAccountManager::Tools::do_log('error', "Failed to delete a Serviceprovider in DB"); - return undef; - } -} ## Print the content of a test account sub print { -- GitLab