Color::Palette::Schema - requirements for a palette


Color-Palette documentation Contained in the Color-Palette distribution.

Index


Code Index:

NAME

Top

Color::Palette::Schema - requirements for a palette

VERSION

Top

version 0.091400

DESCRIPTION

Top

Most of this is documented in Color::Palette. Below is just a bit more documentation.

ATTRIBUTES

Top

required_colors

This is an arrayref of color names that must be present in any palette checked against this schema.

METHODS

Top

check

    $schema->check($palette);

This method will throw an exception if the given palette doesn't meet the requirements of the schema.

AUTHOR

Top

  Ricardo SIGNES <rjbs@cpan.org>

COPYRIGHT AND LICENSE

Top


Color-Palette documentation Contained in the Color-Palette distribution.

package Color::Palette::Schema;
our $VERSION = '0.091400';

use Moose;
# ABSTRACT: requirements for a palette

use Color::Palette;
use Color::Palette::Types qw(ColorName);
use MooseX::Types::Moose qw(ArrayRef);


has required_colors => (
  is  => 'ro',
  isa => ArrayRef[ ColorName ],
  required => 1,
);


sub check {
  my ($self, $palette) = @_;

  # ->color will throw an exception on unknown colors, doing our job for us.
  # -- rjbs, 2009-05-19
  $palette->color($_) for @{ $self->required_colors };
}

1;

__END__