NAME

DCI::Context - Implementation of the DCI concept of a context, also known as a use-case.

DESCRIPTION

In DCI a context defines an encapsulation of business logic, or of an algorithm. A context should define a set of 'roles' (See DCI::Cast), casts data objects to "play" those roles, and kick off a set of interactions between the roles that accomplishes a given task.

SYNOPSIS

This is a very trivial example. See DCI for a complete example including data, Context, and Cast classes.

package MyContext::Divide;
use strict;
use warnings;

# This will add DCI::Context::Base to @ISA for us.
use DCI::Context;

cast numerator   => MyContext::Divide::Numerator,
     denominator => MyContext::Divide::Denominator;

# If we want to hook into construction, this will be called just before
# new() returns.
sub init {
    my $self = shift;
    ...
}

sub do_divide {
    my $self = shift;
    return $self->numerator->value / $self->denominator->value;
}

EXPORTS

When you use DCI::Context it imports the following functions that allow you to manipulate metadata for the Context object.

$meta = CONTEXT_META()

Get the metadata hash for this Context class.

$current_roles = cast( role => $cast_package, ... )

Define roles for the context object, specifying what Cast package should be used for the role. Any number of roles may be defined, and cast(...) may be called any number of times.

cast() also returns all currently defined roles.

CAST CLASS/OBJECT METHODS

These are methods defined by the DCI::Context::Base package:

my $context = $class->new( roleA => $data, ... )

Create a new instance of the context with the specied $data objects fulfilling the specified roles.

DCI RESOURCES

http://www.artima.com/articles/dci_vision.html
http://en.wikipedia.org/wiki/Data,_Context_and_Interaction
https://sites.google.com/a/gertrudandcope.com/www/thedciarchitecture

AUTHORS

Chad Granum exodist7@gmail.com

COPYRIGHT

Copyright (C) 2011 Chad Granum

DCI is free software; Standard perl licence.

DCI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.