From: Jesse Luehrs Date: Thu, 5 May 2011 15:33:14 +0000 (-0500) Subject: mention duck_type in ::Manual::Types X-Git-Tag: 2.0100~178 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ebedd0797d13ce13a2f45db9dbcd85cf6f242b60;p=gitmo%2FMoose.git mention duck_type in ::Manual::Types --- diff --git a/lib/Moose/Manual/Types.pod b/lib/Moose/Manual/Types.pod index cd0dde6..1b7d873 100644 --- a/lib/Moose/Manual/Types.pod +++ b/lib/Moose/Manual/Types.pod @@ -318,9 +318,7 @@ coercion might be a better answer. For our example above, we might want to be more specific, and insist that output be an object with a C method: - subtype 'CanPrint' - => as 'Object' - => where { $_->can('print') }; + duck_type 'CanPrint', [qw(print)]; We can coerce file handles to an object that satisfies this condition with a simple wrapper class: @@ -360,8 +358,8 @@ make your class internals simpler. The L module exports a number of helper functions for creating specific kinds of types. These include -C, C, and C. See the docs for -details. +C, C, C, and C. See the +docs for details. One helper worth noting is C, which allows you to create a subtype of C that only allows the specified values: