has 'baz' => (is => 'rw');
has 'bar' => (is => 'rw', isa => 'Foo');
- #has 'boo' => (is => 'rw', isa => type 'CustomFoo' => where { blessed($_) && $_->isa('Foo') });
+}
+
+{
+ package Bar;
+
+ sub new { bless {} => __PACKAGE__ }
+ sub bar {
+ my $self = shift;
+ $self->{bar} = shift if @_;
+ $self->{bar};
+ }
}
my $foo = Foo->new;
+my $bar = Bar->new;
cmpthese(200_000,
{
+ 'hand coded' => sub {
+ $bar->bar($bar);
+ },
'w/out_constraint' => sub {
$foo->baz($foo);
},
'w_constraint' => sub {
$foo->bar($foo);
- },
- #'w_custom_constraint' => sub {
- # $foo->boo($foo);
- #},
+ },
}
);