Caleb Cushing's Blog Also known as XenoTerraCide
Posts with the tag Moose:

Writing deprecation notices in perl, optionally with Moose

| 278 words | perl deprecation Moose code

Sometimes you want to remove behavior from your code in a future version, here’s the right way to do it.

 READ MORE 

Moose Interface Pattern with parameter enforcement

| 134 words | object oriented design perl Interfaces Moose
Moose interfaces are problematic, for 2 reasons. They are compile time, but runtime features such as attribute delegation could provide the interface (role ordering is the real problem here) They don’t ensure anything other than the method name. I think this problem can be solved better by using around instead of requires package Interface::Create; use Moose::Role; use Type::Params qw( compile ); use Types::Standard qw( slurpy HashRef); around create => sub { my $orig = shift; my $self = shift; state $check = compile( slurpy HashRef ); my ( $obj_args ) = $check->( @_ ); return $self->$orig( $obj_args ); }; 1; Ordering of course still matters here as you can have multiple around modifiers on a method.
 READ MORE