Skip to content

Instantly share code, notes, and snippets.

### Keybase proof
I hereby claim:
* I am 0branch on github.
* I am marcs (https://keybase.io/marcs) on keybase.
* I have a public key whose fingerprint is 0839 E1C9 FF90 1E41 FB1A 0EF7 7F47 6083 7774 14BC
To claim this, I am signing this object:
#!/usr/bin/env perl
use strict;
use warnings;
use feature 'say';
say "Hello from Gist";
@0branch
0branch / Player.pm
Created April 2, 2011 17:00
Player.pm, first draft.
package Player;
use Moose;
has 'inventory' => (
default => sub { [] },
is => 'ro',
);
sub list_inventory {
my $self = shift;
@0branch
0branch / Entity.pm
Created April 2, 2011 17:02
Entity.pm (redraft of Object.pm)
package Entity;
use Moose;
has 'name' => (
isa => 'Str',
is => 'rw',
required => 1,
);
has 'description' => (
@0branch
0branch / Player.pm
Created April 2, 2011 17:02
Player.pm, third draft.
package Player;
use Moose;
has 'inventory' => (
handles => { obtain => 'push' },
isa => 'ArrayRef[Entity]',
default => sub { [] },
traits => ['Array'],
is => 'ro',
);
@0branch
0branch / object-constraint.pl
Created April 2, 2011 17:14
moose definition of Object type constraint
subtype 'Object' => as 'Ref' =>
where { blessed($_) && blessed($_) ne 'Regexp' } =>
optimize_as \&Moose::Util::TypeConstraints::OptimizedConstraints::Object;
@0branch
0branch / Player.pm
Created April 2, 2011 17:01
Player.pm, second draft.
package Player;
use Moose;
has 'inventory' => (
handles => { obtain => 'push' },
isa => 'ArrayRef[Object]',
default => sub { [] },
traits => ['Array'],
is => 'ro',
);
@0branch
0branch / entity.pl
Created April 2, 2011 17:03
entity.pl, third draft
#!/usr/bin/env perl
use strict;
use warnings;
use feature 'say';
use Entity;
use Player;
my $lamp = Entity->new(name => "lamp");
@0branch
0branch / mismatch.pl
Created April 2, 2011 17:24
Example of type mismatching for Str in Moose
#!/usr/bin/env perl
use strict;
use warnings;
use Object;
my $foo = Object->new(name => "lamp");
my $bar = Object->new(name => {});
@0branch
0branch / Object.pm
Created April 2, 2011 16:59
Object class, first draft.
package Object;
use Moose;
has 'name' => (
isa => 'Str',
is => 'rw',
required => 1,
);
has 'description' => (