| Object-eBay documentation | Contained in the Object-eBay distribution. |
Object::eBay::Boolean - Represents a boolean return value
# assuming that $item is an Object::eBay::Item object
my $private = $item->seller->is_feedback_private();
# In string context, yields 'true' or 'false'
print "Is the feedback private? $private\n";
# In boolean context, yields 1 or 0
if ($private) {
print "Feedback is private\n";
}
else {
print "Feedback is public\n";
}
Many of eBay's API calls return boolean (true/false) values. An Object::eBay::Boolean object represents this boolean return value in a context-aware way. In boolean context, the value is simply a boolean value as expected. In string context, the value is eBay's literal 'true' or 'false' value.
A class method that returns a new Object::eBay::Boolean object representing true.
A class method that returns a new Object::eBay::Boolean object representing false.
This method implements the boolean context. Namely
if ( $x->as_boolean() ) { ... }
is the same as
if ($x) { ... }
This method implements the string context. Namely
print "Example: " . $x->as_string() . "\n";
is the same as
print "Example: $x\n";
If an Object::eBay::Boolean object is constructed with a value other than 'true' or 'false', this exception is thrown. Seeing this exception most likely indicates an error (or change) in eBay's XML response.
Object::eBay::Boolean requires no configuration files or environment variables.
None known.
Please report any bugs or feature requests to
bug-object-ebay at rt.cpan.org, or through the web interface at
http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Object-eBay.
I will be notified, and then you'll automatically be notified of progress on
your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc Object::eBay;
You can also look for information at:
Michael Hendricks <michael@ndrix.org>
Copyright (c) 2006 Michael Hendricks (<michael@ndrix.org>). All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Object-eBay documentation | Contained in the Object-eBay distribution. |
package Object::eBay::Boolean; our $VERSION = '0.4.0'; use Class::Std; { use warnings; use strict; use Carp; my %value_for :ATTR( :get<value> ); sub BUILD { my ($self, $ident, $args_ref) = @_; my $details = $args_ref->{object_details} || q{}; croak "Invalid boolean value '$details'\n" unless $details eq 'true' || $details eq 'false'; $value_for{$ident} = $details && $details eq 'true' ? 1 : 0; } sub as_string :STRINGIFY { my ($self) = @_; return $self->get_value() ? 'true' : 'false'; } sub as_boolean :BOOLIFY { my ($self) = @_; return $self->get_value(); } sub true { shift->new({ object_details => 'true' }) } sub false { shift->new({ object_details => 'false' }) } } 1; __END__