diff --git a/lib/WebGUI/Session/Setting.pm b/lib/WebGUI/Session/Setting.pm index ffb6054c6..1daee428d 100644 --- a/lib/WebGUI/Session/Setting.pm +++ b/lib/WebGUI/Session/Setting.pm @@ -87,16 +87,25 @@ sub DESTROY { #------------------------------------------------------------------- -=head2 get ( ) +=head2 get ( $param ) Returns a hash reference containing all the settings. +=head3 $param + +If $param is defined, then it will return only the setting for that param. + =cut sub get { - my $self = shift; - my $param = shift; - return $self->{_settings}{$param}; + my $self = shift; + my $param = shift; + if (defined $param) { + return $self->{_settings}{$param}; + } + else { + return $self->{_settings}; + } } diff --git a/t/Session/Setting.t b/t/Session/Setting.t index 29a6a657e..934460ed3 100644 --- a/t/Session/Setting.t +++ b/t/Session/Setting.t @@ -15,7 +15,7 @@ use lib "$FindBin::Bin/../lib"; use WebGUI::Test; use WebGUI::Session; -use Test::More tests => 6; # increment this value for each test you create +use Test::More tests => 7; # increment this value for each test you create my $session = WebGUI::Test->session; @@ -32,3 +32,4 @@ my ($value) = $session->db->quickArray("select value from settings where name='i is($value, undef, "delete()"); isa_ok($session->setting->session, 'WebGUI::Session', 'session method returns a session object'); +isa_ok($session->setting->get, 'HASH', '->get with no parameters returns a hashref');