NAME
Gapp::Form::Context - Form context object
SYNOPSIS
# use an object
$o = Foo::Character->new( fname => 'Mickey', lname => 'Mouse' );
$cx = Gapp::Form::Context->new(
  reader_prefix => 'get_',
  writer_prefix => 'set_'
);
$cx->add( 'character', $o );
$cx->lookup( 'character.fname' ); # returns 'Mickey'
# use a hash-ref
$data = { foo => 'bar' };
$cx->add( data => $data,
    accessor => sub {
      my ( $data, $attr, $value ) = @_;
      @_ == 2 ? $data{$attr} : $data{$attr} = $value;
    }
);
$cx->lookup( 'data.foo' ); # returns 'Bar'
DESCRIPTION
The context is used to sync data between objects/data structures and forms.
OBJECT HIERARCHY
PROVIDED ATTRIBUTES
- accessor
 - 
If
accessoris defined, it will be used as the default accessor for nodes in the context. The accessor is used to update and retrieve data from the data sctructure. If no accessor is set, reader and writer methods will be used. - reader_prefix
 - 
If
reader_prefixis defined, it will be used as the defaultreader_prefixfor nodes in the context. When doing alookup, thereader_prefixis appended to beginning of the attribute name to form the reader method. This method will then be called on the data structure to retrieve the value. If anaccessorhas been defined, that will be used instead. - writer_prefix
 - 
If
writer_prefixis defined, it will be used as the defaultwriter_prefixfor nodes in the context. When doing amodify, thewriter_prefixis appended to beginning of the attribute name to form the writer method. This method will then be called on the data structure to store the value. If anaccessorhas been defined, that will be used instead. 
PROVIDED METHODS
- add $node_name, $data_structure|CodeRef, @opts
 - 
Add a node to the context. All nodes must have name. The
$data_structureis theObjector other data to work on. If any options are specified, they will over-ride those set by the context. The avaialble options areaccessor,reader_prefix,writer_prefix. - lookup $path
 - 
Retrieves a value from the context.
$pathis a string in the format of "node_name.attribute". - get_node $node_name
 - 
Retrieves a Gapp::Form::Context::Node from the context with the given
$node_name. - modify $path, $new_value
 - 
Sets a value in the context.
$pathis a string in the format of "nodename.attribute". - set_node $node_name, $node
 - 
Add Gapp::Form::Context::Node to the context with the given
$name. - update $stash
 - 
Updates the values in the context based on values in the
$stash.$stashis a Gapp::Form::Stash object. 
AUTHORS
Jeffrey Ray Hallock <jeffrey.hallock at gmail dot com>
COPYRIGHT & LICENSE
Copyright (c) 2011-2012 Jeffrey Ray Hallock.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.