About Site Map Submit Contact Us Log in | Create an account
Create an account Log In
Average Rating
User Rating:
Visitors Rating:
My rating:

Write review
See full specifications

linux default iconObject::Trampoline Publisher's description

Object::Trampoline is a Perl module for delay object construction.

Object::Trampoline is a Perl module for delay object construction, and optionally using the class' module, until a method is actually dispatched, simplifies runtime definition of handler classes.


# adding "use_class" will perform an "eval use $class"
# at the point where the object is first accessed.

use Object::Trampoline;

# the real class name is added to the normal constructor
# and 'Object::Trampoline' used instead. the destination
# class' constructor is called when object is actually
# used for something.

my $dbh = Object::Trampoline->connect( 'DBI', $dsn, $user, $pass, $conf );

my $sth = $dbh->prepare( 'select foo from bar' );

# or specify the package and args from a config file
# or via inherited data.
# the constructor lives in the destination class
# and has nothing to do with Object::Trampoline.

my %config = Config->read( $config_file_path );

my ( $class, $const, @argz )
= @config{ qw( class const args ) };

my $handle = Object::Trampoline->$const( $class, @argz );

# at this point ref $handle is 'Object::Trampoline::Bounce'.

$handle->frobnicate( @stuff );

# at this point ref $handle is $class

# there are times when it is helpful to delay using
# the object's class module until the object is
# instantiated. O::T::U adds the caller's package
# and a "use $class" before the constructor.

my $lazy = Object::Trampoline::Use->frobnicate( $class, @stuff );

my $result = $lazy->susan( 'dessert' );

There are times when constructing an object is expensive or has to be delayed -- database handles in heavily forked apache servers are one example. This module creates a "trampoline" object: when called it replaces the object you have with the object you want. The module itself consists only of two AUTOLOADS: one with captures the constructor call, the other the first method call. The first class blesses a closure which creates the necessary object into the second class, which replces $_[0] with a new object and re-dispatches the call into the proper class.

Using an autoload as the constructor allows Object::Trampoline to use whatever constructor name the "real" class uses without having to pass it as another argument.

System Requirements:

No special requirements.
Program Release Status: Minor Update
Program Install Support: Install and Uninstall

Object::Trampoline Tags:

Click on a tag to find related softwares

Is Object::Trampoline your software?

Manage your software

Most Popular

linux default icon GDB 7.4
GDB, the GNU Project debugger, allows you to see what is going on `inside' another program while it... Read more
linux default icon Coral 0.9.1
Coral is a tool and a development platform to create and transform models and modeling languages.
linux default icon Forum Paid Plus Script 6.1
Forum Paid Pay Per Post Exchange is targeted at forum owners who wish to...
linux default icon sdo 0.6.5
Converts oracle SDO_GEOMETRY objects to WKT and GeoJSON.
linux default icon Get Paid Plus Script 6.1
Get Paid Plus Script

Related Category

» Other (877)
» Tools & Editors (359)
» Web Development (146)