develooper Front page | perl.moose | Postings from July 2008

Defining a parameterized subtype

Thread Next
From:
Guillaume Rousse
Date:
July 14, 2008 14:16
Subject:
Defining a parameterized subtype
Hello list.

I'd like to define my own parameterized ClassName subtype, to enforce 
inheritance from a given class. Something more generic than

subtype 'FooClassName'
     => as 'ClassName'
     => where { $_->isa('Foo') };

subtype 'BarClassName'
     => as 'ClassName'
     => where { $_->isa('Bar') };

etc...

I found a 'add_parameterizable_type' method in 
Moose::Util::TypeConstraints, but not much details about to retrieve the 
parameter in the constraint clause.
-- 
Guillaume Rousse
Moyens Informatiques - INRIA Futurs
Tel: 01 69 35 69 62

Thread Next


Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About