Hub::Knots::TiedObject - Tied object
Part of the Hub Library
In your class:
package __Package_Name__; use Hub qw(:lib); sub new { my $self = shift; my $class = ref( $self ) || $self; my $obj = bless {}, $class; tie %$obj, 'Hub::Knots::TiedObject', '__Tie_Package__'; return $obj; }#new
Perl5 does not let one implement tie methods for a normal blessed package. To get around this, the above constructor ties the blessed reference to this package, providing '__Tie_Package__' as the package which should implement the tie methods.
To transparently provide `tie' methods inline with an existing class. For example, one may have a User class which supports several methods, such as `print', and we wish to update the database on the fly...
my $user = new User( $conn, 'mary', 'alzxjVT8kR.aU' ); $user->{'lname'} = "Lopez"; $user->print();
TiedObject simply provides two hashes for the object: `public' and `private'. When data members are accessed, the 'public' hash is acted upon. If the index begins with an asterisk (*) then the private hash is used. The only value currently in the private hash is the reference to the tied object. In the above class '__Package_Name__':
$self->{'*tied'};
Points to the reference returned by tie-ing '__Tie_Package__' to the public hash.
Hub::Data::Nest
Tie interface method
Usage: TIEHASH 'Hub::Knots::TiedObject', $PACKAGE
Determine which key (public or private) to use
Ryan Gies
Copyright (c) 2006 Livesite Networks, LLC. All rights reserved.
Copyright (c) 2000-2005 Ryan Gies. All rights reserved.
This file created by mkdocs.pl on 8/29/2006 at 2:07pm
To install Hub, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Hub
CPAN shell
perl -MCPAN -e shell install Hub
For more information on module installation, please visit the detailed CPAN module installation guide.