-
-
26 Oct 2009 05:58:06 UTC
- Distribution: Scalar-Util-Instance
- Module version: 0.001
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Repository
- Issues (1)
- Testers (568 / 7 / 12)
- Kwalitee
Bus factor: 1- 100.00% Coverage
- License: perl_5
- Perl: v5.8.1
- Activity
24 month- Tools
- Download (24.53KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
and 1 contributors- Goro Fuji (gfx) <gfuji(at)cpan.org>
- Dependencies
- unknown
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
Scalar::Util::Instance - Generates and installs is-a predicates
VERSION
This document describes Scalar::Util::Instance version 0.001.
SYNOPSIS
use Scalar::Util::Instance { for => 'Foo', as => 'is_a_Foo' }, { for => 'Bar', as => 'is_a_Bar' }, ; # ... if(is_a_Foo($_)){ # ... } elsif(is_a_Bar($_)){ # ... }
DESCRIPTION
Scalar::Util::Instance provides is-a predicates to look up an is-a hierarchy for specific classes. This is an alternative to
blessed($obj) && $obj->isa(...)
, but is significantly faster than it.INTERFACE
Utility functions
Scalar::Util::Instance->generate_for(ClassName, ?PredicateName)
Generates an is-a predicate function for ClassName.
If PredicateName is specified, the method installs the generated function as that name. Otherwise returns an anonymous CODE reference.
An is-a predicate is a function which is the same as the following:
sub is_a_some_class { my($obj) = @_; return Scalar::Util::blessed($obj) && $obj->isa($ClassName); }
DEPENDENCIES
Perl 5.8.1 or later, and a C compiler.
BUGS
No bugs have been reported.
Please report any bugs or feature requests to the author.
SEE ALSO
AUTHOR
Goro Fuji (gfx) <gfuji(at)cpan.org>
LICENSE AND COPYRIGHT
Copyright (c) 2009, Goro Fuji (gfx). Some rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Module Install Instructions
To install Scalar::Util::Instance, copy and paste the appropriate command in to your terminal.
cpanm Scalar::Util::Instance
perl -MCPAN -e shell install Scalar::Util::Instance
For more information on module installation, please visit the detailed CPAN module installation guide.