This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
commit 5e16b74d5058b9a960716894049ca582375330e7
tree 2e564bc50393a5fb6dbb4fc472a041ac727ec2ea
parent 7b86ae53ed8773749900030a0c8955f807af8909
tree 2e564bc50393a5fb6dbb4fc472a041ac727ec2ea
parent 7b86ae53ed8773749900030a0c8955f807af8909
| name | age | message | |
|---|---|---|---|
| |
.cvsignore | Fri Oct 10 15:33:28 -0700 2008 | |
| |
.gitignore | Fri Oct 17 11:39:35 -0700 2008 | |
| |
.screenrc | Sat Apr 11 17:07:24 -0700 2009 | |
| |
Changes | ||
| |
GNUmakefile | Fri Oct 10 15:33:28 -0700 2008 | |
| |
MANIFEST | ||
| |
Makefile.PL | ||
| |
README | ||
| |
lib/ | ||
| |
t/ |
README
NAME
MooseX::Scaffold - Template metaprogramming with Moose
VERSION
Version 0.03
SYNOPSIS
package MyScaffolder;
use MooseX::Scaffold;
MooseX::Scaffold->setup_scaffolding_import;
sub SCAFFOLD {
my $class = shift; my %given = @_;
$class->has($given{kind} => is => 'ro', isa => 'Int', required => 1);
# Using MooseX::ClassAttribute
$class->class_has(kind => is => 'ro', isa => 'Str', default => $given{kind});
}
package MyAppleClass;
use Moose;
use MooseX::ClassAttribute;
use MyScaffolder kind => 'apple';
package MyBananaClass;
use Moose;
use MooseX::ClassAttribute;
use MyScaffolder kind => 'banana';
# ... meanwhile, back at the Batcave ...
use MyAppleClass;
use MyBananaClass;
my $apple = MyAppleClass->new(apple => 1);
my $banana = MyBananaClass->new(banana => 2);
DESCRIPTION
MooseX::Scaffold is a tool for creating or augmenting Moose classes
on-the-fly.
Scaffolding can be triggered when a "use" is executed (any import
arguments are passed to the scaffold subroutine) or you can explicitly
call MooseX::Scaffold->scaffold with the scaffolding subroutine and the
package name for the class.
Depending on what you're trying to do, MooseX::Scaffold can behave in
three different ways (Assume My::Class is the class you're trying to
create/augment):
load_and_scaffold (scaffold) - Attempt to require My::Class from My/Class.pm or do
Moose::Meta::Class->create('My::Class')
to make the package on-the-fly. Scaffold the result.
load_or_scaffold (load) - Attempt to require My::Class from My/Class.pm and stop if that works. If no
My/Class.pm is
found in @INC, then make a Moose class on-the-fly and scaffold it.
This option can be used to create a default class if one isn't found.
scaffold_without_load - Don't attempt to require My::Class, just create it on-the-fly and scaffold it.
METHODS
MooseX::Scaffold->scaffold( ... )
Scaffold a class by either loading it or creating it. You can pass
through the following:
scaffolder
scaffolding_package This should be either a subroutine (sub { ... }) or a package name. If a package name
is given, then the package should contain a subroutine called SCAFFOLD
class
class_package The package name of resulting class
load_or_scaffold Attempt to load $class_package first and do nothing successful. Otherwise create
$class_package and scaffold it
scaffold_without_load Scaffold $class_package without attempting to load it first. Does not have
any effect if $class_package has been loaded already
no_class_attribute Set this to 1 to disable applying the MooseX::ClassAttribute meta-role
on class creation. This has no effect if the class is loaded (If you
want class_has with a loaded class, make sure to 'use MooseX::ClassAttribute')
MooseX::Scaffold->load_and_scaffold( ... )
An alias for ->scaffold
MooseX::Scaffold->load_or_scaffold( ... )
An alias for ->scaffold with "load_or_scaffold" set to 1
MooseX::Scaffold->load( ... )
An alias for ->load_or_scaffold
MooseX::Scaffold->scaffold_without_load( ... )
An alias for ->scaffold with "scaffold_without_load" set to 1
MooseX::Scaffold->build_scaffolding_import( ... )
Return an anonymous subroutine suitable for use an an import function
Anything passable to ->scaffold is fair game. In addition:
scaffolder This will default to the package of caller() if unspecified
chain_import An (optional) subroutine that will goto'd after scaffolding is complete
MooseX::Scaffold->setup_scaffolding_import( ... )
Install an import subroutine. By default, caller() will be used for the
exporting package, but another may be specified.
Anything passable to ->build_scaffolding_import is fair game. In
addition:
exporter
exporting_package The package that will house the import subroutine (the scaffolding will trigger
when the package is used or imported)
MooseX::Scaffold->load_package( $package )
MooseX::Scaffold->load_class( $class )
A convenience method that will attempt to require $package or $class if
not already loaded
Essentially does ...
eval "require $package;" or die $@
... but uses Class::Inspector to check for $package existence first
(%INC is not trustworthy)
AUTHOR
Robert Krimen, "<rkrimen at cpan.org>"
SOURCE
You can contribute or fork this project via GitHub:
<http://github.com/robertkrimen/moosex-scaffold/tree/master>
git clone git://github.com/robertkrimen/moosex-scaffold.git MooseX-Scaffold
BUGS
Please report any bugs or feature requests to "bug-moosex-classscaffold
at rt.cpan.org", or through the web interface at
<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MooseX-Scaffold>. I will
be notified, and then you'll automatically be notified of progress on
your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc MooseX::Scaffold
You can also look for information at:
* RT: CPAN's request tracker
<http://rt.cpan.org/NoAuth/Bugs.html?Dist=MooseX-Scaffold>
* AnnoCPAN: Annotated CPAN documentation
<http://annocpan.org/dist/MooseX-Scaffold>
* CPAN Ratings
<http://cpanratings.perl.org/d/MooseX-Scaffold>
* Search CPAN
<http://search.cpan.org/dist/MooseX-Scaffold>
ACKNOWLEDGEMENTS
COPYRIGHT & LICENSE
Copyright 2008 Robert Krimen, all rights reserved.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.








