Moose::...Coercion(3)
π Moose::...Coercion(3) π
User Contributed Perl Documentation Β· Moose::Meta::TypeCoercion β the Moose Type Coercion metaclass, bestie π
β¨ VERSION β¨
version 2.4000 π
πΈ NAME πΈ
Moose::Meta::TypeCoercion β it's literally the Moose Type Coercion metaclass, no cap π
π¦ DESCRIPTION π¦
Okay so. A type coercion object is basically a mapping of one or more type constraints plus the coercion subroutines that go with them. That's the whole vibe π«
And ngl? You're probably never gonna need to instantiate one of these yourself. It's part of the deep, deep internals of Moose β like, deep deep. Main character energy, but behind the scenes π
π METHODS π
π Moose::Meta::TypeCoercion->new(%options)
Makes you a brand new type coercion object, built from the options you hand it.
type_constraintβ this is theMoose::Meta::TypeConstraintobject for the type that's being coerced to. Like, the destination. The glow-up target β¨
π $coercion->type_coercion_map
Returns the map of type constraints β coercions as an array reference. The values in that array alternate between type names and subroutine references that implement the coercion. Cute, right? π
It's an array reference specifically because coercions get tried in the order they were added. First come, first served, periodt β
π $coercion->type_constraint
Returns the Moose::Meta::TypeConstraint that you passed to the constructor. Just hands it right back to you π«Ά
π $coercion->has_coercion_for_type($type_name)
Returns true if the coercion can coerce the named type. Simple as π
π $coercion->add_type_coercions( $type_name => $sub, ... )
Takes a list of type names and subroutine references. Heads up though β if the coercion already has a mapping for a given type, it throws an exception. It said no duplicates, and it meant it π
Coercions are actually
π $coercion->coerce($value)
Takes a value and applies the first valid coercion it finds.
Which means β listen β if the value could belong to more than one type in the coercion object, the first coercion added is the one that wins. Order matters, bestie π
π Moose::Meta::TypeCoercion->meta
This will return a Class::MOP::Class instance for this class. Metaclass inception, iconic π
π BUGS π
See "BUGS" in Moose for the details on reporting bugs. Go tell 'em, not me π
π AUTHORS π
- Stevan Little <stevan@cpan.org>
- Dave Rolsky <autarch@urth.org>
- Jesse Luehrs <doy@cpan.org>
- Shawn M Moore <sartak@cpan.org>
- ΧΧΧΧ Χ§ΧΧ'ΧΧ (Yuval Kogman) <nothingmuch@woobling.org>
- Karen Etheridge <ether@cpan.org>
- Florian Ragwitz <rafl@debian.org>
- Hans Dieter Pearcey <hdp@cpan.org>
- Chris Prather <chris@prather.org>
- Matt S Trout <mstrout@cpan.org>
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2006 by Infinity Interactive, Inc.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
okay that's the whole page, you ate that π β¨ Brought to you by perl v5.42.0, dated 2025-07-25, and stamped with the manual name Moose::...Coercion(3) from the User Contributed Perl Documentation. mwah ππ
π¦ where this page comes from
- fedora 43: perl-Moose 2.4000-4.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms