MooseX::Types::DBIx::Class::Parameterizable - Parameterizable MooseX::Types for DBIx::Class objects
version 0.02
# in your Moose class use MooseX::Types::DBIx::Class::Parameterizable qw(ResultSet Row); # this attribute must be a DBIx::Class::Row object from your "Album" Result class has album => ( is => 'ro', isa => Row['Album'] ); # this attribute must be a DBIx::Class::ResultSet object from your "Album" ResultSet class has other_albums => ( is => 'ro', isa => ResultSet['Album'] ); # for convenience, these types can act like their non-parameterized base types too has any_resultset => ( is => 'ro', isa => ResultSet ); # subtyping works as expected use MooseX::Types -declare => [qw(RockAlbum DecadeAlbum)]; use Moose::Util::TypeConstraints; subtype RockAlbum, as Row['Album'], where { $_->genre eq 'Rock' }; # Further parameterization! use MooseX::Types::Parameterizable; subtype DecadeAlbum, as Parameterizable[Row['Album'], Str], where { my($album, $decade) = @_; return Row(['Album'])->check($album) && substr($album->year, -2, 1) eq substr($decade, 0, 1); }; subtype EightiesRock, as DecadeAlbum[80], where { $_->genre eq 'Rock' }; has eighties_rock_album => ( is => 'ro', isa => EightiesRock, );
This module provides parameterizable versions of the same types provided by MooseX::Types::DBIx::Class.
This type constraint requires the object to be an instance of DBIx::Class::ResultSet and to have the specified $source_name (if specified).
$source_name
This type constraint requires the object to be an instance of DBIx::Class::ResultSource and to have the specified $source_name (if specified).
This type constraint requires the object to be an instance of DBIx::Class::Row and to have the specified $source_name (if specified).
This type constraint is present mostly for completeness and requires the object to be an instance of DBIx::Class::Schema and to have a class name that matches $class_name or the regular expression if specified.
$class_name
Oliver Charles <oliver@ocharles.org.uk>, Brian Phillips
This software is copyright (c) 2010 by Oliver Charles.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install MooseX::Types::DBIx::Class, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooseX::Types::DBIx::Class
CPAN shell
perl -MCPAN -e shell install MooseX::Types::DBIx::Class
For more information on module installation, please visit the detailed CPAN module installation guide.