Max Maischein > DBIx-VersionedSubs-0.07 > DBIx::VersionedSubs::Hash

Download:
DBIx-VersionedSubs-0.07.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Module Version: 0.07   Source  

NAME ^

DBIx::VersionedSubs::Hash - store subroutines in a simple hash

SYNOPSIS ^

  package My::App;
  use strict;
  use base 'DBIx::VersionedSubs::Hash';

  __PACKAGE__->{code} = {
      say_hello => sub {print "Hello World"},
  };

  package main;
  use strict;

  my $app = My::App->new({code => {},dsn => $dsn );
  while (my $request = Some::Server->get_request) {
      $app->update_code(); # update code from the DB
      $app->handle_request->($request);
  }

ABSTRACT ^

This module overrides some methods in DBIx::VersionedSubs and replaces the normal namespace based code storage with simple storage in a hash. This is useful if you want multiple code versions in a mod_perl environment for example.

Package->new({ %ARGS })

Creates a new object and initializes it from the class default values as inherited from DBIx::VersionedSubs.

If you pass in a hashref to the code key, all subroutines will be stored in it. You can also use this feature to pass in a package hash (like %My::App:: ), then this module will be almost identical in usage to DBIx::VersionedSubs itself. The difference between the two is that subroutine names with characters outside of \w will not create subroutines in other namespaces with this module.

$app->dispatch( FUNCTION, ARGS )

This is a shorthand method for

    return $self->{code}->{$function}->(@ARGS);

except with error checking

AUTHOR ^

Max Maischein, <corion@cpan.org>

LICENSE ^

This module is licensed under the same terms as Perl itself.

syntax highlighting: