Zing::Domain - Aggregate Root
Aggregate Root Construct
use Zing::Domain; my $domain = Zing::Domain->new(name => 'user-1'); # $domain->recv;
This package provides an aggregate abstraction and real-time cross-process sharable data structure which offers many benefits, not least being able to see a full history of state changes.
This package uses type constraints from:
Zing::Types
This package has the following attributes:
channel(Channel)
This attribute is read-only, accepts (Channel) values, and is optional.
(Channel)
name(Str)
This attribute is read-only, accepts (Str) values, and is required.
(Str)
This package implements the following methods:
apply() : Object
The apply method receives events from the channel and applies the operations.
# given: synopsis $domain->apply;
change(Str $op, Str $key, Any @val) : Object
The change method commits an operation (and snapshot) to the channel. This method is used internally and shouldn't need to be called directly.
# given: synopsis $domain->change('incr', 'karma', 1);
data() : HashRef
The data method returns the raw aggregate data associated with the object.
# given: synopsis $domain->data;
decr(Str $key, Int $val = 1) : Object
The decr method decrements the data associated with a specific key.
# given: synopsis $domain->decr('karma');
# given: synopsis $domain->decr('karma', 2);
del(Str $key) : Object
The del method deletes the data associated with a specific key.
# given: synopsis $domain->del('missing');
# given: synopsis $domain->set('email', 'me@example.com'); $domain->del('email');
get(Str $key) : Any
The get method return the data associated with a specific key.
# given: synopsis $domain->get('email');
# given: synopsis $domain->set('email', 'me@example.com'); $domain->get('email');
incr(Str $key, Int $val = 1) : Object
The incr method increments the data associated with a specific key.
# given: synopsis $domain->incr('karma');
# given: synopsis $domain->incr('karma', 5);
pop(Str $key) : Object
The pop method pops the data off of the stack associated with a specific key.
# given: synopsis $domain->pop('history');
push(Str $key, Any @val) : Object
The push method pushes data onto the stack associated with a specific key.
# given: synopsis $domain->push('history', { updated => 1234567890 });
set(Str $key, Any $val) : Object
The set method commits the data associated with a specific key to the channel.
# given: synopsis $domain->set('updated', 1234567890);
shift(Str $key) : Object
The shift method shifts data off of the stack associated with a specific key.
# given: synopsis $domain->shift('history');
unshift(Str $key, Any @val) : Object
The unshift method unshifts data onto the stack associated with a specific key.
# given: synopsis $domain->unshift('history', { updated => 1234567890 });
Al Newkirk, awncorp@cpan.org
awncorp@cpan.org
Copyright (C) 2011-2019, Al Newkirk, et al.
This is free software; you can redistribute it and/or modify it under the terms of the The Apache License, Version 2.0, as elucidated in the "license file".
Wiki
Project
Initiatives
Milestones
Contributing
Issues
To install Zing, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Zing
CPAN shell
perl -MCPAN -e shell install Zing
For more information on module installation, please visit the detailed CPAN module installation guide.