NAME
Hub::Knots::TiedObject - Tied object
Part of the Hub Library
SYNOPSIS
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
DESCRIPTION
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.
Intention
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();
Implementation
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.
See also:
METHODS
INTERNAL
CLEAR | FETCH | SCALAR | UNTIE |
DELETE | FIRSTKEY | STORE | _key |
EXISTS | NEXTKEY | TIEHASH |
- CLEAR
-
Tie interface method
- DELETE
-
Tie interface method
- EXISTS
-
Tie interface method
- FETCH
-
Tie interface method
- FIRSTKEY
-
Tie interface method
- NEXTKEY
-
Tie interface method
- SCALAR
-
Tie interface method
- STORE
-
Tie interface method
- TIEHASH
-
Tie interface method
Usage: TIEHASH 'Hub::Knots::TiedObject', $PACKAGE
- UNTIE
-
Tie interface method
AUTHOR
Ryan Gies
COPYRIGHT
Copyright (c) 2006 Livesite Networks, LLC. All rights reserved.
Copyright (c) 2000-2005 Ryan Gies. All rights reserved.
UPDATED
This file created by on at