Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Moose removed from tests

  • Loading branch information...
commit 7a318896825f177004e3812103bf9bd8d242de98 1 parent 4ddddf6
Zbigniew Lukasiak authored zby committed
View
3  lib/WebNano/Controller.pm
@@ -99,10 +99,13 @@ __END__
WebNano::Controller
=head1 SYNOPSIS
+With Moose:
package MyApp::Controller;
use Moose;
+ use MooseX::NonMoose;
+
extends 'WebNano::Controller';
has '+url_map' => ( default => sub { { 'Mapped Url' => 'mapped_url' } } );
View
2  lib/WebNano/FindController.pm
@@ -19,7 +19,7 @@ sub find_nested {
$controller_class =~ s{/}{::}g;
}
catch {
- if( $_ !~ /Can't locate .*$sub_path.pm in \@INC/ ){
+ if( $_ !~ /Can't locate $controller_file in \@INC/ ){
die $_;
}
};
View
37 t/lib/MyApp.pm
@@ -1,31 +1,24 @@
+use strict;
+use warnings;
+
package MyApp;
-use Moose;
-use MooseX::NonMoose;
-extends 'WebNano';
+use base 'WebNano';
+use Class::XSAccessor { accessors => [ 'config' ], };
use Config::Any;
use WebNano::TTTRenderer;
-has config => ( is => 'ro', isa => 'HashRef', lazy_build => 1 );
-
-sub _build_config {
- my( $self ) = @_;
- return $self->get_config( 't/data/app' );
-}
-
-has renderer => ( is => 'ro', lazy_build => 1 );
-sub _build_renderer {
- my $self = shift;
- my $config = $self->config->{renderer};
- return WebNano::TTTRenderer->new( %$config );
-}
-
-sub get_config {
- my( $self, $conf_file ) = @_;
-
- my $cfg = Config::Any->load_stems({ stems => [ $conf_file ], use_ext => 1 });
+sub new {
+ my $class = shift;
+ my $self = $class->SUPER::new( @_ );
+ my $cfg = Config::Any->load_stems({ stems => [ $self->config_file ], use_ext => 1 });
my @values = values %{$cfg->[0]};
- return $values[0];
+ my $config = $values[0];
+ $self->config( $config );
+ $self->renderer( WebNano::TTTRenderer->new( %{ $config->{renderer} } ) );
+ return $self;
}
+sub config_file { 't/data/app' }
+
1;
View
15 t/lib/MyApp/Controller.pm
@@ -1,10 +1,17 @@
+use strict;
+use warnings;
+
package MyApp::Controller;
-use Moose;
-use MooseX::NonMoose;
-extends 'WebNano::Controller';
+use base 'WebNano::Controller';
+
-has 'url_map' => ( is => 'ro', default => sub { { 'mapped url' => 'mapped_url' } } );
+sub new {
+ my $class = shift;
+ my $self = $class->SUPER::new( @_ );
+ $self->url_map( { 'mapped url' => 'mapped_url' } );
+ return $self;
+}
sub index_action {
my $self = shift;
View
15 t/lib/MyApp/Controller/NestedController.pm
@@ -1,10 +1,15 @@
-package MyApp::Controller::NestedController;
-use Moose;
-use MooseX::NonMoose;
+use strict;
+use warnings;
-extends 'WebNano::Controller';
+package MyApp::Controller::NestedController;
+use base 'WebNano::Controller';
-has 'url_map' => ( is => 'ro', default => sub { [ 'safe_method' ] } );
+sub new {
+ my $class = shift;
+ my $self = $class->SUPER::new( @_ );
+ $self->url_map( [ 'safe_method' ] );
+ return $self;
+}
sub safe_method { 'This is the safe_method page' }
View
7 t/lib/MyApp/Controller/NestedController2.pm
@@ -1,8 +1,9 @@
+use strict;
+use warnings;
+
package MyApp::Controller::NestedController2;
-use Moose;
-use MooseX::NonMoose;
-extends 'WebNano::Controller';
+use base 'WebNano::Controller';
sub some_method_action { 'This is a method with _action postfix in MyApp::Controller::NestedController2' }
View
11 t/lib/MyApp/Controller/WebDispatchTable.pm
@@ -1,11 +0,0 @@
-package MyApp::Controller::WebDispatchTable;
-
-use WebNano::Controller::WebDispatchTable::Moose;
-
-extends 'WebNano::Controller::WebDispatchTable';
-
-get '/' => sub { 'This is index in web_dispatch table' };
-get '/some_address' => sub { 'This is some_address in web_dispatch table' };
-
-1;
-
View
12 t/lib/SubClassApp.pm
@@ -1,14 +1,12 @@
+use strict;
+use warnings;
+
package SubClassApp;
-use Moose;
-extends 'MyApp';
+use base 'MyApp';
-sub _build_config {
- my( $self ) = @_;
- return $self->get_config( 't/data/subclassapp' );
-}
+sub config_file { 't/data/subclassapp' }
sub controller_search_path { [ ref(shift), 'MyApp' ] };
-
1;
Please sign in to comment.
Something went wrong with that request. Please try again.