| 1 | # Copyright Infomation | ||||||||||
| 2 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||
| 3 | # Author : Dr. Ahmed Amin Elsheshtawy, Ph.D. | ||||||||||
| 4 | # Website: https://github.com/mewsoft/Nile, http://www.mewsoft.com | ||||||||||
| 5 | # Email : mewsoft@cpan.org, support@mewsoft.com | ||||||||||
| 6 | # Copyrights (c) 2014-2015 Mewsoft Corp. All rights reserved. | ||||||||||
| 7 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||
| 8 | package Nile::Base; | ||||||||||
| 9 | |||||||||||
| 10 | 1 | our $VERSION = '0.55'; | |||||||||
| 11 | 1 | our $AUTHORITY = 'cpan:MEWSOFT'; | |||||||||
| 12 | |||||||||||
| 13 | =pod | ||||||||||
| 14 | |||||||||||
| 15 | =encoding utf8 | ||||||||||
| 16 | |||||||||||
| 17 | =head1 NAME | ||||||||||
| 18 | |||||||||||
| 19 | Nile::Base - Base class for the Nile framework. | ||||||||||
| 20 | |||||||||||
| 21 | =head1 SYNOPSIS | ||||||||||
| 22 | |||||||||||
| 23 | package Nile::MyModule; | ||||||||||
| 24 | |||||||||||
| 25 | use Nile::Base; | ||||||||||
| 26 | |||||||||||
| 27 | 1; | ||||||||||
| 28 | |||||||||||
| 29 | =head1 DESCRIPTION | ||||||||||
| 30 | |||||||||||
| 31 | Nile::Base - Base class for the Nile framework. | ||||||||||
| 32 | |||||||||||
| 33 | =cut | ||||||||||
| 34 | |||||||||||
| 35 | 1 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 36 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 37 | 1 | ▶ | use MooseX::Declare; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 38 | 1 | ▶ | use MooseX::MethodAttributes; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 39 | 1 | ▶ | use Import::Into; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 40 | 1 | ▶ | use Module::Runtime qw(use_module); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 41 | #use true; # both load and import it | ||||||||||
| 42 | #use Nile::Declare; | ||||||||||
| 43 | |||||||||||
| 44 | 1 | ▶ | use Nile::Say; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 45 | #use Nile::Declare ('method' => 'method', 'function' => 'function', 'invocant'=>'$this', 'inject'=>'my ($me) = $this->me;'); | ||||||||||
| 46 | |||||||||||
| 47 | 1 | ▶ | no warnings 'redefine'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 48 | 1 | ▶ | no strict 'refs'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 49 | # disable the auto immutable feature of Moosex::Declare, or use class Nile::Home is mutable {...} | ||||||||||
| 50 | 0 | ▶ | *{"MooseX::Declare::Syntax::Keyword::Class" . '::' . "auto_make_immutable"} = sub { 0 }; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.4
| |||||||||||
| 51 | #around auto_make_immutable => sub { 0 }; | ||||||||||
| 52 | |||||||||||
| 53 | 1 | our @EXPORT_MODULES = ( | |||||||||
| 54 | #strict => [], | ||||||||||
| 55 | #warnings => [], | ||||||||||
| 56 | Moose => [], | ||||||||||
| 57 | utf8 => [], | ||||||||||
| 58 | #true => [], | ||||||||||
| 59 | 'Nile::Say' => [], | ||||||||||
| 60 | #'Nile::Declare' => ['method' => 'method', 'function' => 'function', 'invocant'=>'$self', 'inject'=>'my ($me) = $self->me;'], | ||||||||||
| 61 | 'MooseX::Declare' => [], | ||||||||||
| 62 | #'Nile::Declare' => [], | ||||||||||
| 63 | 'MooseX::MethodAttributes' => [], | ||||||||||
| 64 | #'MooseX::ClassAttribute' => [], | ||||||||||
| 65 | #'Module::Load' => [()], # will emit error for methods load redefined | ||||||||||
| 66 | ); | ||||||||||
| 67 | |||||||||||
| 68 | 16 | ▶ | sub import { | ||||||||
|
Subroutine
import: called CC=3 SCAR=11.0
| |||||||||||
| 69 | 16 | my ($class, %args) = @_; | |||||||||
| 70 | 16 | my $caller = caller; | |||||||||
| 71 | 16 | my @modules = @EXPORT_MODULES; | |||||||||
| 72 | 16 | ▶ | while (@modules) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 73 | 80 | my $module = shift @modules; | |||||||||
| 74 | 80 | ▶ | my $imports = ref $modules[0] eq 'ARRAY' ? shift @modules : []; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 75 | 80 | use_module($module)->import::into($caller, @{$imports}); | |||||||||
| 76 | } | ||||||||||
| 77 | } | ||||||||||
| 78 | |||||||||||
| 79 | =pod | ||||||||||
| 80 | |||||||||||
| 81 | =head1 Bugs | ||||||||||
| 82 | |||||||||||
| 83 | This project is available on github at L<https://github.com/mewsoft/Nile>. | ||||||||||
| 84 | |||||||||||
| 85 | =head1 HOMEPAGE | ||||||||||
| 86 | |||||||||||
| 87 | Please visit the project's homepage at L<https://metacpan.org/release/Nile>. | ||||||||||
| 88 | |||||||||||
| 89 | =head1 SOURCE | ||||||||||
| 90 | |||||||||||
| 91 | Source repository is at L<https://github.com/mewsoft/Nile>. | ||||||||||
| 92 | |||||||||||
| 93 | =head1 SEE ALSO | ||||||||||
| 94 | |||||||||||
| 95 | See L<Nile> for details about the complete framework. | ||||||||||
| 96 | |||||||||||
| 97 | =head1 AUTHOR | ||||||||||
| 98 | |||||||||||
| 99 | Ahmed Amin Elsheshtawy, احمد امين الششتاوى <mewsoft@cpan.org> | ||||||||||
| 100 | Website: http://www.mewsoft.com | ||||||||||
| 101 | |||||||||||
| 102 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 103 | |||||||||||
| 104 | Copyright (C) 2014-2015 by Dr. Ahmed Amin Elsheshtawy احمد امين الششتاوى mewsoft@cpan.org, support@mewsoft.com, | ||||||||||
| 105 | L<https://github.com/mewsoft/Nile>, L<http://www.mewsoft.com> | ||||||||||
| 106 | |||||||||||
| 107 | This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. | ||||||||||
| 108 | |||||||||||
| 109 | =cut | ||||||||||
| 110 | |||||||||||
| 111 | 1 | 1; | |||||||||