Workflow::Context - Data blackboard for Workflows, Actions, Conditions and Validators


Workflow documentation Contained in the Workflow distribution.

Index


Code Index:

NAME

Top

Workflow::Context - Data blackboard for Workflows, Actions, Conditions and Validators

VERSION

Top

This documentation describes version 1.05 of this package

SYNOPSIS

Top

 # Create your own context and merge it with one that may already be
 # in a workflow

 my $context = Workflow::Context->new();
 $context->param( foo => 'bar' );
 $context->param( current_user => User->fetch( 'foo@bar.com' ) );
 $wf->context( $context );

 # In a Condition get the 'current_user' back out of the workflow's context

 sub evaluate {
     my ( $self, $wf ) = @_;
     my $current_user = $wf->context->param( 'current_user' );
     ...
 }

 # Set values directly into a workflow's context

 $wf->context->param( foo => 'bar' );
 $wf->context->param( news => My::News->fetch_where( 'date = ?', DateTime->now ) );

DESCRIPTION

Top

Holds information to pass between your application and a Workflow, including its Actions, Conditions and Validators.

OBJECT METHODS

Top

merge( $other_context )

Merges the values from $other_context into this object. If there are duplicate keys in this object and $other_context, $other_context wins.

SEE ALSO

Top

Workflow

COPYRIGHT

Top

AUTHORS

Top

Jonas B. Nielsen (jonasbn) <jonasbn@cpan.org>, current maintainer.

Chris Winters <chris@cwinters.com>, original author.


Workflow documentation Contained in the Workflow distribution.

package Workflow::Context;

# $Id: Context.pm 454 2009-01-12 10:04:02Z jonasbn $

use warnings;
use strict;
use base qw( Workflow::Base );

$Workflow::Context::VERSION = '1.05';

sub merge {
    my ( $self, $other ) = @_;
    my $other_params = $other->param();
    while ( my ( $k, $v ) = each %{$other_params} ) {
        $self->param( $k, $v );
    }
}

1;

__END__