| HTML-FormFu documentation | Contained in the HTML-FormFu distribution. |
HTML::FormFu::Deflator::PathClassFile - Deflator for Path::Class::File objects
$form->deflator( PathClassFile => 'file' )
->relative( 'root' );
---
elements:
- type: Text
deflator:
- type: PathClassFile
relative: root
Deflator for Path::Class::File objects.
There are three types of deflation:
Set this to 1 to deflate to a relative path. Anything else than 1 specifies the directory to use as the base of relativity - otherwise the current working directory will be used.
Set this to 1 to deflate to an absolute path. Anything else than 1 specifies the directory to use as the base of relativity - otherwise the current working directory will be used.
Set this to 1 to get the name of the file without the directory portion.
As you cannot set values for a File element, this deflator will only work on regular form elements.
Moritz Onken, onken@houseofdesign.de
This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself.
| HTML-FormFu documentation | Contained in the HTML-FormFu distribution. |
package HTML::FormFu::Deflator::PathClassFile; use Moose; extends 'HTML::FormFu::Deflator'; has relative => ( is => 'rw', traits => ['Chained'] ); has absolute => ( is => 'rw', traits => ['Chained'] ); has basename => ( is => 'rw', traits => ['Chained'] ); sub deflator { my ( $self, $value ) = @_; return $value unless ( ref $value ); # we default to relative(1) $self->relative(1) unless ( $self->absolute || $self->basename || $self->relative ); if ( $self->relative ) { return $value->relative( $self->relative eq "1" ? undef : $self->relative )->stringify; } elsif ( $self->absolute ) { return $value->absolute( $self->absolute eq "1" ? undef : $self->absolute )->stringify; } elsif ( $self->basename ) { return $value->basename; } # fallback, should never happen return $value->stringify; } __PACKAGE__->meta->make_immutable; 1; __END__