diff --git a/lib/WebGUI/Shop/ShipDriver.pm b/lib/WebGUI/Shop/ShipDriver.pm index 0bdb285ec..148ac2c40 100644 --- a/lib/WebGUI/Shop/ShipDriver.pm +++ b/lib/WebGUI/Shop/ShipDriver.pm @@ -156,6 +156,34 @@ sub delete { #------------------------------------------------------------------- +=head2 get ( [ $param ] ) + +This is an enhanced accessor for the options property. By default, +it returns all the options as a hashref. If the name of a key +in the hash is passed, it will only return that value from the +options hash. + +=head3 $param + +An optional parameter. If it matches the key of a hash, it will +return the value from the options hash. + +=cut + +sub get { + my $self = shift; + my $param = shift; + my $options = $self->options; + if (defined $param) { + return $options->{$param}; + } + else { + return $options; + } +} + +#------------------------------------------------------------------- + =head2 getID ( ) Returns the shipperId. This is an alias for shipperId provided diff --git a/t/Shop/ShipDriver.t b/t/Shop/ShipDriver.t index 41ab549b6..1da8f8966 100644 --- a/t/Shop/ShipDriver.t +++ b/t/Shop/ShipDriver.t @@ -29,7 +29,7 @@ my $session = WebGUI::Test->session; #---------------------------------------------------------------------------- # Tests -my $tests = 21; +my $tests = 24; plan tests => 1 + $tests; #---------------------------------------------------------------------------- @@ -148,6 +148,16 @@ cmp_deeply( is ($driver->getName, 'Shipper Driver', 'getName returns the human readable name of this driver'); +####################################################################### +# +# get +# +####################################################################### + +cmp_deeply($driver->get, $driver->options, 'get works like the options method with no param passed'); +is($driver->get('enabled'), 1, 'get the enabled entry from the options'); +is($driver->get('label'), 'Slow and dangerous', 'get the label entry from the options'); + ####################################################################### # # getEditForm