This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package R1; | |
use Moose::Role; | |
sub foo { | |
warn 'R1::foo' | |
} | |
package R2; | |
use Moose::Role; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Logger; | |
use Moose; | |
has 'fout', is => 'ro', lazy_build => 1; | |
has 'filename', is => 'ro'; | |
sub _build_fout { | |
my $self = shift; | |
my $fh; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Photo; | |
use Moose; | |
has 'likes' => ( | |
is => 'rw', | |
clearer => 'unpublish', | |
predicate => 'is_published', | |
); | |
sub publish { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Course; | |
use Moose; | |
has 'students' => ( | |
is => 'ro', | |
isa => 'ArrayRef[Student]', | |
default => sub { [] }, | |
); | |
sub add_student { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use v5.14; | |
package Zombie; | |
use Moose; | |
has 'victims', is => 'ro', isa => 'ArrayRef[Human]'; | |
has 'home', is => 'ro', isa => 'Str'; | |
sub eat_brain { | |
my $self = shift; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use v5.14; | |
package Person; | |
use Moose; | |
use Moose::Util::TypeConstraints; | |
has 'eyecolor' => ( | |
is => 'ro', | |
isa => enum [qw/gray blue brown green/]; | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use v5.14; | |
package Person::Types; | |
use Moose::Util::TypeConstraints; | |
enum 'Person::Types::EyeColor', [qw/gray brown green blue/]; | |
package Person; | |
use Moose; | |
use Moose::Util::TypeConstraints; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use v5.14; | |
package Student; | |
use Moose; | |
use Moose::Util::TypeConstraints; | |
subtype 'GradesArray', as 'ArrayRef[Int]'; | |
coerce 'GradesArray', from 'Int', via { [ $_ ] }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Paper; use Moose; | |
package Scissors; use Moose; | |
package Rock; use Moose; | |
package Game; | |
use Moose; | |
use MooseX::MultiMethods; | |
multi method play (Paper $x, Rock $y) { 1 } | |
multi method play (Scissors $x, Paper $y) { 1 } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use v5.14; | |
my %cache; | |
package MyDevice; | |
use Moose; | |
sub talk_to_device { return 7 } | |
package MyDummyDevice; |