Andrew Sterling Hanenkamp > Form-Factory > Form::Factory::Result::Single

Download:
Form-Factory-0.020.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Module Version: 0.020   Source  

NAME ^

Form::Factory::Result::Single - Form result class representing a single result

VERSION ^

version 0.020

SYNOPSIS ^

  my $result = Form::Factory::Result::Single->new;

  $result->is_valid(1);
  $result->is_success(1);
  $result->success('success! Hurray! Yippee! Woohoo!');
  $result->failure('failure! Shucks! Bummer! Glurgh!');

  $result->info('something happened');
  $result->warning('something happened, beware!');
  $result->error('nothing happened. Ohnoes!');

  $result->field_info(foo => 'consider this info about foo');
  $result->field_warning(bar => 'bar worked, but you should check it again');
  $result->field_error(baz => 'baz is wrong');

  $result->clear_messages_for_field('foo');
  $result->clear_messages;

DESCRIPTION ^

This class provides an individual Form::Factory::Result.

ATTRIBUTES ^

is_valid

A boolean value indicating whether the action checked out okay. When set, the is_validated predicate is set to true.

is_success

A boolean value indicating whether the action ran okay. When set, the is_outcome_known predicate is set to true.

messages

This is the array of Form::Factory::Message objects attached to this result.

content

This is a hash of other information to attach to the result. This can be anything the action needs to output to the caller. This can be useful for returning references to newly created objects, automatically assigned IDs, etc.

METHODS ^

add_message

  $result->add_message(%options);

The %options are passed to the constructor of Form::Factory::Message. The new message object is added to the end of "messages".

clear_state

Clears the is_valid and is_success flags (which also clears is_failure, is_validated, and is_outcome_known). This also resets content to an empty hash.

clear_messages

Empties the list of messages in "messages".

clear_messages_for_field

  $result->clear_messages_for_field($field);

Clears all messages that are tied to the named field.

info

  $result->info($message);

Adds a new regular info message.

field_info

  $result->field_info($field, $message);

Adds a new info message tied to the named field.

warning

  $result->warning($message);

Adds a new regular warning messages.

field_warning

  $result->field_warning($field, $message);

Adds a new warning message tied to the named field.

error

  $result->error($message);

Adds a new regular error message.

field_error

  $result->field_error($field, $message);

Adds a new error message tied to the named field.

success

  $result->success($message);

This is shorthand for:

  $result->is_success(1);
  $result->info($message);

failure

  $result->failure($message);

This is shorthand for:

  $result->is_success(0);
  $result->error($message);

AUTHOR ^

Andrew Sterling Hanenkamp <hanenkamp@cpan.org>

COPYRIGHT AND LICENSE ^

Copyright 2009 Qubling Software LLC.

This library is free software. You can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: