Skip to content

Instantly share code, notes, and snippets.

@genehack
Created May 4, 2013 17:37
Show Gist options
  • Select an option

  • Save genehack/5518188 to your computer and use it in GitHub Desktop.

Select an option

Save genehack/5518188 to your computer and use it in GitHub Desktop.
package Base;
use Moose;
has 'base' => ( is => 'ro' , isa => 'Str' , default => 'base' );
package App;
use Moose;
extends 'Base';
has 'app' => ( is => 'ro' , isa => 'Str' , default => 'app' );
package App::DB;
use Moose;
extends 'App';
has 'db' => ( is => 'ro' , isa => 'Str' , default => 'db' );
package App::DB::Mysql;
use Moose;
extends 'App::DB';
has '+db' => ( default => 'mysql' );
package App::DB::PostgreSQL;
use Moose;
extends 'App::DB';
has '+db' => ( default => 'postgres' );
package main;
use strict;
use warnings;
use 5.010;
my $db = App::DB->new;
my $my = App::DB::Mysql->new;
my $pg = App::DB::PostgreSQL->new;
say $_->db foreach ( $db , $my , $pg );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment