NAME

Smart::Dispatch::Match - an entry in a dispatch table

DESCRIPTION

Smart::Dispatch::Match is a Moose class. (Well, Moo actually, but close enough.)

Constructor

  • new(%attributes)

    Create a new entry.

Attributes

  • test

    is 'ro', required.

  • dispatch

    is 'ro', isa 'CodeRef', predicate has_dispatch.

  • value

    is 'ro', predicate has_value.

  • note

    is 'ro', isa 'Str'.

  • is_failover

    is 'ro', isa 'Bool', required, default false.

  • is_unconditional

    is 'ro', isa 'Bool', required, default false.

Methods

  • value_matches($value)

    Perform a smart match between $value and the test attribute.

  • conduct_dispatch(@args)

    If the Match object has a dispatch coderef, then calls it, passing @args as arguments, and passing through the return value.

    Else if the Match object has a value, just returns it.

    Otherwise returns nothing.

  • bitflags

    Returns a number representing what sort of match this is (conditional, failover, etc), suitable for bitwise operations with the constants defined by this module.

Constants

  • FLAG_HAS_VALUE

  • FLAG_HAS_DISPATCH

  • FLAG_IS_FAILOVER

  • FLAG_IS_UNCONDITIONAL

Overloads

Smart::Dispatch::Match overloads various operations. (See overload.)

  • code derefernce &{} - conduct_dispatch.

  • smart match ~~ - value_matches.

BUGS

Please report any bugs to http://rt.cpan.org/Dist/Display.html?Queue=Smart-Dispatch.

SEE ALSO

Smart::Dispatch.

AUTHOR

Toby Inkster <tobyink@cpan.org>.

COPYRIGHT AND LICENCE

This software is copyright (c) 2012 by Toby Inkster.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

DISCLAIMER OF WARRANTIES

THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.