diff --git a/lib/Encomp/Class/Encompasser.pm b/lib/Encomp/Class/Encompasser.pm index f550317..487e27e 100644 --- a/lib/Encomp/Class/Encompasser.pm +++ b/lib/Encomp/Class/Encompasser.pm @@ -20,7 +20,7 @@ sub operate { $obj->{context} = $context; if (my $codes = $hooks->{$self->{path_cached} || $self->get_path}) { for my $code (@{$codes}) { - $code->($obj, $context, @args); + $code->($obj, @args); } } undef $obj->{context}; diff --git a/lib/Encomp/Context.pm b/lib/Encomp/Context.pm index a57f652..5f627d0 100644 --- a/lib/Encomp/Context.pm +++ b/lib/Encomp/Context.pm @@ -5,14 +5,15 @@ use warnings; use base qw/Class::Accessor::Fast/; use Carp qw/croak/; -__PACKAGE__->mk_accessors qw/return skip error _goto/; +__PACKAGE__->mk_accessors qw/return skip _goto/; +#__PACKAGE__->mk_accessors qw/return skip error _goto/; sub new { my $class = shift; $class->SUPER::new({ return => 0, skip => 0, - errors => [], +# errors => [], current => undef, _goto => undef, }); @@ -24,7 +25,6 @@ sub current { $self->{current} = $hook; return unless $self->{skip}; if ($hook eq $self->{_goto}) { - $self->skip(0); $self->clear_goto; } } @@ -48,11 +48,16 @@ sub goto { } } -sub clear_goto { undef $_[0]->{_goto} } -sub error_number { scalar @{ $_[0]->errors } } -sub has_error { scalar @{ $_[0]->errors } ? 1 : 0 } -sub add_errors { push @{ shift->errors } => @_ } -sub clear_errors { @{ $_[0]->errors } = () } +sub clear_goto { + my $self = shift; + $self->_goto(undef); + $self->skip(0); +} + +#sub error_number { scalar @{ $_[0]->errors } } +#sub has_error { scalar @{ $_[0]->errors } ? 1 : 0 } +#sub add_errors { push @{ shift->errors } => @_ } +#sub clear_errors { @{ $_[0]->errors } = () } 1; diff --git a/t/05_process.t b/t/05_process.t index f8941d0..014db2d 100644 --- a/t/05_process.t +++ b/t/05_process.t @@ -16,25 +16,25 @@ processes 5 => [qw/ 1 2 3 /], ; -hook_to '/1/1' => sub { my ($self, $ctx) = @_; $self->body('/1/1'); $ctx->goto('/2') }; -hook_to '/1/2' => sub { my ($self, $ctx) = @_; $self->body('/1/2'); $ctx->goto('/2/2') }; -hook_to '/1/3' => sub { my ($self, $ctx) = @_; $self->body('/1/3'); $ctx->goto('/2/3') }; - -hook_to '/2/1' => sub { my ($self, $ctx) = @_; $self->body('/2/1'); $ctx->goto('/3') }; -hook_to '/2/2' => sub { my ($self, $ctx) = @_; $self->body('/2/2'); $ctx->goto('/3/2') }; -hook_to '/2/3' => sub { my ($self, $ctx) = @_; $self->body('/2/3'); $ctx->goto('/3/3') }; - -hook_to '/3/1' => sub { my ($self, $ctx) = @_; $self->body('/3/1'); $ctx->goto('/4') }; -hook_to '/3/2' => sub { my ($self, $ctx) = @_; $self->body('/3/2'); $ctx->goto('/4/2') }; -hook_to '/3/3' => sub { my ($self, $ctx) = @_; $self->body('/3/3'); $ctx->goto('/4/3') }; - -hook_to '/4/1' => sub { my ($self, $ctx) = @_; $self->body('/4/1'); $ctx->goto('/5') }; -hook_to '/4/2' => sub { my ($self, $ctx) = @_; $self->body('/4/2'); $ctx->goto('/5/2') }; -hook_to '/4/3' => sub { my ($self, $ctx) = @_; $self->body('/4/3'); $ctx->goto('/5/3') }; - -hook_to '/5/1' => sub { my ($self, $ctx) = @_; $self->body('/5/1'); $ctx->goto('/1/2') }; -hook_to '/5/2' => sub { my ($self, $ctx) = @_; $self->body('/5/2'); $ctx->goto('/1/3') }; -hook_to '/5/3' => sub { my ($self, $ctx) = @_; $self->body('/5/3') }; +hook_to '/1/1' => sub { my $self = shift; $self->body('/1/1'); $self->context->goto('/2') }; +hook_to '/1/2' => sub { my $self = shift; $self->body('/1/2'); $self->context->goto('/2/2') }; +hook_to '/1/3' => sub { my $self = shift; $self->body('/1/3'); $self->context->goto('/2/3') }; + +hook_to '/2/1' => sub { my $self = shift; $self->body('/2/1'); $self->context->goto('/3') }; +hook_to '/2/2' => sub { my $self = shift; $self->body('/2/2'); $self->context->goto('/3/2') }; +hook_to '/2/3' => sub { my $self = shift; $self->body('/2/3'); $self->context->goto('/3/3') }; + +hook_to '/3/1' => sub { my $self = shift; $self->body('/3/1'); $self->context->goto('/4') }; +hook_to '/3/2' => sub { my $self = shift; $self->body('/3/2'); $self->context->goto('/4/2') }; +hook_to '/3/3' => sub { my $self = shift; $self->body('/3/3'); $self->context->goto('/4/3') }; + +hook_to '/4/1' => sub { my $self = shift; $self->body('/4/1'); $self->context->goto('/5') }; +hook_to '/4/2' => sub { my $self = shift; $self->body('/4/2'); $self->context->goto('/5/2') }; +hook_to '/4/3' => sub { my $self = shift; $self->body('/4/3'); $self->context->goto('/5/3') }; + +hook_to '/5/1' => sub { my $self = shift; $self->body('/5/1'); $self->context->goto('/1/2') }; +hook_to '/5/2' => sub { my $self = shift; $self->body('/5/2'); $self->context->goto('/1/3') }; +hook_to '/5/3' => sub { my $self = shift; $self->body('/5/3') }; no Encomp; diff --git a/t/lib/DemoFW.pm b/t/lib/DemoFW.pm index fb61c5d..0e6284d 100644 --- a/t/lib/DemoFW.pm +++ b/t/lib/DemoFW.pm @@ -12,18 +12,18 @@ plugins 'DemoFW::Plugin::Response'; hook_to '/initialize' => sub { - my ($self, $context, @args) = @_; + my ($self, @args) = @_; }; hook_to '/main' => sub { - my ($self, $context, @args) = @_; + my ($self, @args) = @_; $self->dispatch; }; hook_to '/finalize' => sub { - my ($self, $context, @args) = @_; + my ($self, @args) = @_; print $self->headers_out; print "\n"; print $self->output;