Object::eBay::Attribute - Represents an item attribute


Object-eBay documentation Contained in the Object-eBay distribution.

Index


Code Index:

NAME

Top

Object::eBay::Attribute - Represents an item attribute

SYNOPSIS

Top

    # assuming that $item is an Object::eBay::Item object
    my $attribute = $item->attributes->find(10244);
    print "The condition is $attribute\n";  # "The condition is New"
    if ( $attribute == 24227 ) {
        print "This is a Sega Genesis game\n";
    }

DESCRIPTION

Top

eBay associates key-value pairs (attributes) with certain auctions. An Object::eBay::Attribute object represents a specific attribute of an auction.

METHODS

Top

get_attribute_id

Returns an ID number for the type of this attribute.

get_value_id

Returns an ID number for the value of this attribute. This method is called when the attribute object is used in numeric context.

get_value_literal

Returns a string for the value of this attribute. This method is called when the attribute object is used in string context.

AUTHOR

Top

Michael Hendricks <michael@ndrix.org>

LICENSE AND COPYRIGHT

Top


Object-eBay documentation Contained in the Object-eBay distribution.

package Object::eBay::Attribute;
our $VERSION = '0.4.0';

use Class::Std; {
    use warnings;
    use strict;
    use overload
        q{""}    => 'get_value_literal',
        q{0+}    => 'get_value_id',
        fallback => 1
    ;
    use Carp;

    my %attribute_id_for  :ATTR( :get<attribute_id>  );
    my %value_id_for      :ATTR( :get<value_id>      );
    my %value_literal_for :ATTR( :get<value_literal> );

    sub BUILD {
        my ( $self, $ident, $args_ref ) = @_;
        my $hash = $args_ref->{attribute} || {};
        $attribute_id_for{$ident}  = $hash->{attributeID};
        $value_id_for{$ident}      = $hash->{Value}{ValueID};
        $value_literal_for{$ident} = $hash->{Value}{ValueLiteral};
    }
}

1;

__END__