The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

SimpleDB::Class::Item - An object representation from an item in a SimpleDB domain.

VERSION

version 0.0100

DESCRIPTION

An object representation from an item in a SimpleDB domain.

METHODS

The following methods are available from this class.

new ( params )

Constructor.

params

A hash.

id

The unique identifier (ItemName) of the item represented by this class. If you don't pass this in, an item ID will be generated for you automatically.

domain

Required. A SimpleDB::Class::Domain object.

attributes

Required. A hashref containing the names and values of the attributes associated with this item.

{attribute} ( [ value ] )

For each attribute passed into the constructor, an accessor / mutator will be added to this class allowing you to get or set it's current value.

If specified, sets the current value of the attribute. Note, that this doesn't update the database, for that you must call the put() method.

id ( )

Returns the unique id of this item.

domain ( )

Returns the domain passed into the constructor.

attributes ( )

Returns the attributes passed into the constructor.

add_attribute ( name, [ default, type ] )

Adds an accessor / mutator for a new attribute. Allows you to create a wide range of items with a wide range of attributes that weren't conceived when you wrote the domain object.

name

The attribute name.

default

The default value. Defaults to undef, which is bad because null searches are slow.

type

Valid types are 'Str', 'Int', and 'DateTime'. Defaults to 'Str'.

BUILD ( )

Generates the relationship methods and attribute methods on object construction. See Moose for details.

copy ( [ id ] )

Creates a duplicate of this object, inserts it into the database, and returns a reference to it.

id

If you want to assign a specific id to the copy, then you can do it with this parameter.

delete

Removes this item from the database.

delete_attribute

Removes a specific attribute from this item in the database. Great in conjunction with add_attribute().

generate_uuid ( )

Class method. Generates a unique UUID that can be used as a unique id for new items.

put ( )

Inserts/updates the current attributes of this Item object to the database.

AUTHOR

JT Smith <jt_at_plainblack_com>

I have to give credit where credit is due: SimpleDB::Class is heavily inspired by DBIx::Class by Matt Trout (and others), and the Amazon::SimpleDB class distributed by Amazon itself (not to be confused with Amazon::SimpleDB written by Timothy Appnel).

LEGAL

SimpleDB::Class is Copyright 2009 Plain Black Corporation and is licensed under the same terms as Perl itself.