From 15d3ec323ae3dfd9325419a2b0adad2eacab0058 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Sat, 26 May 2007 04:08:01 +0000 Subject: [PATCH] Add hashwide getters for AdSpace and Ad.pm Fix a bug in Ad/set where if no properties were passed it would die. --- lib/WebGUI/AdSpace.pm | 6 +++++- lib/WebGUI/AdSpace/Ad.pm | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/WebGUI/AdSpace.pm b/lib/WebGUI/AdSpace.pm index d637c7d96..d0a4eeb1a 100644 --- a/lib/WebGUI/AdSpace.pm +++ b/lib/WebGUI/AdSpace.pm @@ -158,7 +158,11 @@ The name of the property to retrieve the value for. sub get { my $self = shift; my $name = shift; - return $self->{_properties}{$name}; + if (defined $name) { + return $self->{_properties}{$name} + } + my %copyOfProperties = %{ $self->{_properties} }; + return \%copyOfProperties; } #------------------------------------------------------------------- diff --git a/lib/WebGUI/AdSpace/Ad.pm b/lib/WebGUI/AdSpace/Ad.pm index 8c9cf2dcf..f993afe4a 100644 --- a/lib/WebGUI/AdSpace/Ad.pm +++ b/lib/WebGUI/AdSpace/Ad.pm @@ -115,7 +115,11 @@ The name of the property to retrieve the value for. sub get { my $self = shift; my $name = shift; - return $self->{_properties}{$name}; + if (defined $name) { + return $self->{_properties}{$name} + } + my %copyOfProperties = %{ $self->{_properties} }; + return \%copyOfProperties; } #------------------------------------------------------------------- @@ -239,7 +243,7 @@ The number of times the user has paid for this ad to be displayed on the site. sub set { my $self = shift; - my $properties = shift; + my $properties = shift || {}; $self->{_properties}{title} = $properties->{title} || $self->{_properties}{title} || "Untitled"; $self->{_properties}{clicksBought} = $properties->{clicksBought} || $self->{_properties}{clicksBought}; $self->{_properties}{impressionsBought} = $properties->{impressionsBought} || $self->{_properties}{impressionsBought};