| 1 | 113 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 2 | 113 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | |||
| 4 | package Jifty::Param; | ||
| 5 | |||
| 6 | =head1 NAME | ||
| 7 | |||
| 8 | Jifty::Param - Parameters for Jifty actions | ||
| 9 | |||
| 10 | =head1 DESCRIPTION | ||
| 11 | |||
| 12 | Describes a parameter to a C<Jifty::Action> object. Do not construct | ||
| 13 | this by hand -- use L<Jifty::Param::Schema> in the action package to | ||
| 14 | declare parameters instead. | ||
| 15 | |||
| 16 | =head2 accessors | ||
| 17 | |||
| 18 | Although this class is not derived from B<Jifty::Web::Form::Field>, | ||
| 19 | it does share the accessors from it; see L<Jifty::Web::Form::Field>, | ||
| 20 | for the list of possible keys that each parameter can have. | ||
| 21 | |||
| 22 | In addition to the list there, you may use these additional keys: | ||
| 23 | |||
| 24 | =over | ||
| 25 | |||
| 26 | =item constructor | ||
| 27 | |||
| 28 | A boolean which, if set, indicates that the argument B<must> be | ||
| 29 | present in the C<arguments> passed to create the action, rather than | ||
| 30 | being expected to be set later. | ||
| 31 | |||
| 32 | Defaults to false. | ||
| 33 | |||
| 34 | =item valid_values | ||
| 35 | |||
| 36 | An array reference. Each element should be either: | ||
| 37 | |||
| 38 | =over 4 | ||
| 39 | |||
| 40 | =item * | ||
| 41 | |||
| 42 | A hash reference with a C<display> field for the string to display for the | ||
| 43 | value, and a C<value> field for the value to actually send to the server. | ||
| 44 | |||
| 45 | =item * | ||
| 46 | |||
| 47 | A hash reference with a C<collection> field containing a L<Jifty::Collection>, | ||
| 48 | and C<display_from> and C<value_from> fields containing the names of methods to | ||
| 49 | call on each record in the collection to get C<display> and C<value>. | ||
| 50 | |||
| 51 | =item * | ||
| 52 | |||
| 53 | A simple string, which is treated as both C<display> and C<value>. | ||
| 54 | |||
| 55 | =back | ||
| 56 | |||
| 57 | =item available_values | ||
| 58 | |||
| 59 | Just like L<valid_values>, but represents the list of suggested values, | ||
| 60 | instead of the list of acceptable values. | ||
| 61 | |||
| 62 | =item sort_order | ||
| 63 | |||
| 64 | An integer of how the parameter sorts relative to other parameters. | ||
| 65 | This is usually implicitly generated by its declaration order. | ||
| 66 | |||
| 67 | =back | ||
| 68 | |||
| 69 | =cut | ||
| 70 | |||
| 71 | |||
| 72 | # We share accessors with Jifty::Web::Form::Field, but not its methods, | ||
| 73 | # so it's not an inheritance relationsip. | ||
| 74 | 113 | ▶ | use Jifty::Web::Form::Field (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 75 | |||
| 76 | 113 | ▶ | use base qw/Class::Accessor::Fast/; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 77 | 113 | ▶ | use constant ACCESSORS => ( |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 78 | Jifty::Web::Form::Field->accessors, | ||
| 79 | qw(constructor valid_values available_values sort_order documentation), | ||
| 80 | 113 | ); | |
| 81 | |||
| 82 | 113 | __PACKAGE__->mk_accessors(ACCESSORS); | |
| 83 | |||
| 84 | 0 | ▶ | sub accessors { ACCESSORS } |
|
Subroutine
accessors: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 85 | |||
| 86 | =head2 new | ||
| 87 | |||
| 88 | Creates a new L<Jifty::Param> object. Note that unlike L<Jifty::Web::Form::Field>, | ||
| 89 | the object is never magically reblessed into a subclass. Should only be called | ||
| 90 | implicitly from a L<Jifty::Param::Schema> declaration. | ||
| 91 | |||
| 92 | =cut | ||
| 93 | |||
| 94 | 0 | ▶ | sub new { |
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 95 | 0 | my $class = shift; | |
| 96 | 0 | $class->Class::Accessor::Fast::new({ | |
| 97 | type => 'text', | ||
| 98 | class => '', | ||
| 99 | input_name => '', | ||
| 100 | default_value => '', | ||
| 101 | sticky_value => '', | ||
| 102 | render_mode => 'update', | ||
| 103 | @_, | ||
| 104 | }); | ||
| 105 | } | ||
| 106 | |||
| 107 | 113 | 1; | |