Yanick Champoux > DBIx-NoSQL-Store-Manager-0.2.1 > DBIx::NoSQL::Store::Manager::Model

Download:
DBIx-NoSQL-Store-Manager-0.2.1.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: v0.2.1   Source   Latest Release: DBIx-NoSQL-Store-Manager-0.2.2

NAME ^

DBIx::NoSQL::Store::Manager::Model - Role for classes to be handled by DBIx::NoSQL::Store::Manager

VERSION ^

version 0.2.1

SYNOPSIS ^

    package MyComics::Model::Comic;

    use strict;
    use warnings;

    use Moose;

    with 'DBIx::NoSQL::Store::Manager::Model';

    has series => (
        traits => [ 'StoreKey' ],
        is => 'ro',
    );

    has issue =>  (
        traits => [ 'StoreKey' ],
        is => 'ro',
        isa => 'Int',
    );

    has penciller => (
        traits => [ 'StoreIndex' ],
        is => 'ro',
    );

    has writer => (
        is => 'ro',
    );

    __PACKAGE__->meta->make_immutable;

    1;

DESCRIPTION ^

Role for classes to be stashed in a DBIx::NoSQL::Store::Manager store.

The only hard-requirement for a class consuming this role is to define a key to be used as the unique id of the object in the store. This can be done by applying the DBIx::NoSQL::Store::Manager::StoreIndex trait to one or more attributes (the key will be the concatenation of those attributes). Or, if the generation of the key is more complicated, it can be done by playing with the store_key attribute directly:

    has '+store_key' => (
        default => sub {
            my $self = shift;

            return $self->generate_arcane_key;
        },
    );

Attributes of the class can be marked for indexed by giving them the DBIx::NoSQL::Store::Manager::StoreIndex trait.

ATTRIBUTES ^

store_db

The DBIx::NoSQL::Store::Manager store to which the object belongs to. Required.

store_model

Class-level attribute holding the model name of the class. If not given, defaults to the class name with everything up to a *::Model:: truncated (e.g., MyStore::Model::Thingy would become Thingy).

Not that as it's a class-level attribute, it can't be passed to new(), but has to be set via class_has:

    class_has +store_model => (
        default => 'SomethingElse',
    );

store_key

The store id of the object. Defaults to the concatenation of the value of all attributes having the DBIx::NoSQL::Store::Manager::StoreKey trait.

METHODS ^

store_db

Returns the DBIx::NoSQL::Store::Manager store to which the object belongs to.

store()

Serializes the object into the store.

delete()

Deletes the object from the store.

AUTHOR ^

Yanick Champoux <yanick@babyl.dyndns.org>

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2012 by Yanick Champoux.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

syntax highlighting: