Form::Factory::Feature::Functional - A generic feature for actions


Form-Factory documentation Contained in the Form-Factory distribution.

Index


Code Index:

NAME

Top

Form::Factory::Feature::Functional - A generic feature for actions

VERSION

Top

version 0.020

SYNOPSIS

Top

  package MyApp::Action::Foo;
  use Form::Factory::Processor;

  has_cleaner squeaky => sub {
      my $action = shift;
      # clean up the action input here...
  };

  has_checker black_or_read => sub {
      my $action = shift;
      # check the action input here... 
  };

  has_pre_processor remember_cpp => sub {
      my $action = shift;
      # run code just before processing here...
  };

  has_post_processor industrial_something => sub {
      my $action = shift;
      # run code just after processing here...
  };

DESCRIPTION

Top

You probably don't want to use this feature directly. The various helpers imported when you use Form::Factory::Processor actually use this feature for implementation. You probably want to use those instead.

ATTRIBUTES

Top

cleaner_code

An array of subroutines to run during the clean phase.

checker_code

An array of subroutines to run during the check phase.

pre_processor_code

An array of subroutines to run during the pre-process phase.

post_process_code

An array of subroutines to run during the post-process phase.

METHODS

Top

clean

Run all the subroutines in cleaner_code.

check

Run all the subroutines in checker_code.

pre_process

Run all the subroutines in pre_processor_code.

post_process

Run all the subroutines in post_processor_code.

AUTHOR

Top

Andrew Sterling Hanenkamp <hanenkamp@cpan.org>

COPYRIGHT AND LICENSE

Top


Form-Factory documentation Contained in the Form-Factory distribution.
package Form::Factory::Feature::Functional;
BEGIN {
  $Form::Factory::Feature::Functional::VERSION = '0.020';
}
use Moose;

with qw( 
    Form::Factory::Feature 
    Form::Factory::Feature::Role::Clean
    Form::Factory::Feature::Role::Check
    Form::Factory::Feature::Role::PreProcess
    Form::Factory::Feature::Role::PostProcess
);

has cleaner_code => (
    is        => 'ro',
    isa       => 'HashRef[CodeRef]',
    required  => 1,
    default   => sub { {} },
);

has checker_code => (
    is        => 'ro',
    isa       => 'HashRef[CodeRef]',
    required  => 1,
    default   => sub { {} },
);

has pre_processor_code => (
    is        => 'ro',
    isa       => 'HashRef[CodeRef]',
    required  => 1,
    default   => sub { {} },
);

has post_processor_code => (
    is        => 'ro',
    isa       => 'HashRef[CodeRef]',
    required  => 1,
    default   => sub { {} },
);

sub clean {
    my $self = shift;
    $_->($self->action, @_) for values %{ $self->cleaner_code };
}

sub check {
    my $self = shift;
    $_->($self->action, @_) for values %{ $self->checker_code };
}

sub pre_process {
    my $self = shift;
    $_->($self->action, @_) for values %{ $self->pre_processor_code };
}

sub post_process {
    my $self = shift;
    $_->($self->action, @_) for values %{ $self->post_processor_code };
}

1;