Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Perl Modules

    DBIx::Class::DynamicSubclass 0.03

    Download button

    No screenshots available
    Downloads: 308  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Pronin Oleg | More programs
    Perl Artistic License / FREE
    May 13th, 2009, 13:31 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    DBIx::Class::DynamicSubclass description

    Convenient way to use dynamic subclassing.

    DBIx::Class::DynamicSubclass is a Perl module that offers a convenient way to use dynamic subclassing.

    SYNOPSIS

     package My::Schema::Game;

     __PACKAGE__->load_components(qw/DynamicSubclass Core/);
     __PACKAGE__->add_column(qw/id name data type/);

     __PACKAGE__->typecast_map(type => {
     1 => 'My::Schema::Game::Online',
     2 => 'My::Schema::Game::Shareware',
     3 => 'My::Schema::Game::PDA',
     });

     $game = $schema->resultset('Game')->new({..., type => 1});
     # ref $game = 'My::Schema::Game::Online'

     @games = $game->search({type => 2});
     # @games are all of class My::Schema::Game::Shareware

     $game->type(3); # game is now of class My::Schema::Game::PDA

     $game = $schema->resultset('Game')->new({});
     # or
     $game->type(undef);
     # game is now of type My::Schema::Game


     #Dynamic properties with DBIx::Class::FrozenColumns
     package My::Schema::Game;
     __PACKAGE__->load_components(qw/... FrozenColumns .../);

     package My::Schema::Game::Online;
     use base 'My::Schema::Game';
     __PACKAGE__->add_frozen_columns(data => qw/flash server_host server_port/);

     package My::Schema::Game::Shareware;
     use base 'My::Schema::Game';
     __PACKAGE__->add_frozen_columns(data => qw/price download_url/);

     ...

     $game->type(1); #game would have now additional columns 'flash', 'server_host', etc.
     $game->server_host('...'); #(stored in 'data')

     $game->type(2);
     $game->server_host; #error
     $game->price('$3.00'); #ok

     $game = $rs->new({
     type => 1,
     flash => 'game.swf',
     }); #ok

     #More flexible way

     package My::Schema::Game;
     __PACKAGE__->typecast_column('type');

     sub classify { #called each time the object gets or losses its 'type'
     my $self = shift;
     #decide which class do you want
     bless $self, $class;
     }



    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    dynamic subclassing | Perl module | Perl | DBIx | dynamic

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM