NAME

DustyDB::Key - mark an attribute as being part of the primary key

VERSION

version 0.06

SYNOPSIS

  package MyModel;
  use DustyDB::Object;

  has key name => ( is => 'rw', isa => 'Str' );
  has description => ( is => 'rw', isa => 'Str' );

DESCRIPTION

This is a basic marker role that just notifies DustyDB that the attribute should be used to define the primary key (one of the attributes that uniquely identifies it) for the object.

ATTRIBUTES

stringify

This may be defined as a reference to a subroutine to be used to translate a non-scalar attribute into a scalar key value. For example, if you want to use a date via DateTime as a key, you could do:

  has key timestamp => (
     is => 'rw',
     isa => 'DateTime',
     stringify => sub { $_->iso8601 },
  );

METHODS

perform_stringify

This is a helper for executing the code reference in the "stringify" attribute correctly.