Acme-Constructor-Pythonic

 view release on metacpan or  search on metacpan

CONTRIBUTING  view on Meta::CPAN

        not, then try <https://github.com/tobyink> or submit a bug report.
        (As far as I'm concerned the lack of a link is a bug.) Many of my
        distributions are also mirrored at <http://bitbucket.org/tobyink>.

        To submit the patch, do a pull request on GitHub or Bitbucket, or
        attach a diff file to a bug report. Unless otherwise stated, I'll
        assume that your contributions are licensed under the same terms as
        the rest of the project.

        (If using git, feel free to work in a branch. For Mercurial, I'd
        prefer bookmarks within the default branch.)

    *   Documentation

        If there's anything unclear in the documentation, please submit this
        as a bug report or patch as above.

        Non-toy example scripts that I can bundle would also be appreciated.

    *   Translation

README  view on Meta::CPAN


        use Acme::Constructor::Pythonic
            'A::Module',
            'Another::Module' => \%some_options,
            'Yes::Another::Module',
        ;

    *   class

        The class to call the constructor on. This is normally the same as the
        module name, and that's the default assumption, so there's no usually
        much point in providing it.

    *   constructor

        The method name for the constructor. The default is `new` which is
        usually correct.

    *   alias

        The name of the function you want created for you. The default is the
        last component of the module name, which is often sensible.

    *   no_require

        Acme::Constructor::Python will automatically load the module
        specified. Not straight away; it waits until you actually perform an
        instantiation. If you don't want Acme::Constructor::Python to load the
        module, then set this option to true.

BUGS

lib/Acme/Constructor/Pythonic.pm  view on Meta::CPAN


my %_CACHE;
sub _exporter_expand_sub
{
	my $me = shift;
	my ($name, $args, $globals) = @_;
	
	# We want to be invisible to Carp
	$Carp::Internal{$me} = 1;
	
	# Process incoming arguments, providing sensible defaults.
	my $module = $name;
	my $class  = defined($args->{class})       ? $args->{class}       : $name;
	my $ctor   = defined($args->{constructor}) ? $args->{constructor} : 'new';
	my $alias  = defined($args->{alias})       ? $args->{alias}       : $name;
	my $req    = exists($args->{no_require})   ? !$args->{no_require} : !$globals->{no_require};
	
	# Doesn't really make sense to include a package name
	# as part of the alias. We were just lazy in initializing
	# the default above.
	$alias = $1 if $alias =~ /::(\w+)\z/;
	
	# We really only need Module::Runtime if $req is on.
	# $req is on by default, but in imagined case where
	# the caller has been diligent enough to no_require
	# every import, we can do them a favour and not
	# needlessly load Module::Runtime into memory.
	if ($req) { require Module::Runtime }
	
	# Compile a custom coderef instead of closing
	# over variables.
	my $code = join("\n",
		sprintf('package %s;', $me),
		defined($globals->{into_line}) && defined($globals->{into_file})

lib/Acme/Constructor/Pythonic.pm  view on Meta::CPAN

        'Yes::Another::Module',
    ;

=over

=item *

B<class>

The class to call the constructor on. This is normally the same as the module
name, and that's the default assumption, so there's no usually much point in
providing it.

=item *

B<constructor>

The method name for the constructor. The default is C<new> which is usually
correct.

=item *

B<alias>

The name of the function you want created for you. The default is the last
component of the module name, which is often sensible.

=item *

B<no_require>

Acme::Constructor::Python will automatically load the module specified. Not
straight away; it waits until you actually perform an instantiation. If you
don't want Acme::Constructor::Python to load the module, then set this option
to true.



( run in 0.467 second using v1.01-cache-2.11-cpan-0a6323c29d9 )