Skip to content
This repository has been archived by the owner on May 17, 2018. It is now read-only.

Commit

Permalink
Make Item->is_ended return a Boolean object
Browse files Browse the repository at this point in the history
This makes the return value of is_* methods more consistent
throughout the module.

Signed-off-by: Michael Hendricks <michael@ndrix.org>
  • Loading branch information
mndrix committed Jun 20, 2008
1 parent 20eb093 commit 625d18b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions Changes
Expand Up @@ -6,6 +6,7 @@ changes :
- Use User->is_feedback_private instead of User->feedback_private
FIXES:
- minor documentation corrections
- make Item->is_ended return a Boolean object for consistency
NEW:
- new true and false methods on the Boolean class
- added ListingDetails->start_time
Expand Down
14 changes: 9 additions & 5 deletions lib/Object/eBay/Item.pm
Expand Up @@ -6,6 +6,7 @@ use Class::Std; {
use strict;
use base qw( Object::eBay );
use overload '""' => 'item_id', fallback => 1;
use Object::eBay::Boolean;

sub api_call { "GetItem" };
sub response_field { "Item" };
Expand Down Expand Up @@ -44,9 +45,12 @@ use Class::Std; {
my $status = $self->selling_status->listing_status;
die "eBay item #$self has no listing status\n" if not defined $status;

return if $status eq 'Active';
return 1 if $status eq 'Ended';
return 1 if $status eq 'Completed';
my $true = Object::eBay::Boolean->true;
my $false = Object::eBay::Boolean->false;

return $false if $status eq 'Active';
return $true if $status eq 'Ended';
return $true if $status eq 'Completed';
die "eBay item #$self has an unknown listing status: $status\n";
}

Expand Down Expand Up @@ -140,8 +144,8 @@ specify C<needs_methods> correctly, this method will not be available.
=head2 is_ended
Returns true if the eBay auction for this item has ended. Otherwise, it
returns false.
Returns an L<Object::eBay::Boolean> true value if the eBay auction for this
item has ended. Otherwise, it returns a false object.
=head2 item_id
Expand Down
6 changes: 3 additions & 3 deletions t/20-item-is_ended.t
Expand Up @@ -19,9 +19,9 @@ my $mocked = Test::MockObject->new;

# test the normal cases
my %tests = (
Active => undef,
Completed => 1,
Ended => 1,
Active => 'false',
Completed => 'true',
Ended => 'true',
);
my $item = Object::eBay::Item->new({ item_id => 12345 });
while ( my ($value, $expected) = each %tests ) {
Expand Down

0 comments on commit 625d18b

Please sign in to comment.