sub _make_by_type {
my ($package, $name, $type) = @_;
_as_number ($package, $name, places => -2) if $type =~ /numeric | real | float/xi;
- _as_percent($package, $name, places => 0) if $type =~ /numeric | real | float/xi;
+ _as_percent($package, $name, places => 2) if $type =~ /numeric | real | float/xi;
_as_number ($package, $name, places => 0) if $type =~ /int/xi;
_as_date ($package, $name) if $type =~ /date | timestamp/xi;
+ _as_bool_yn($package, $name) if $type =~ /bool/xi;
}
sub _as_number {
return 1;
}
+sub _as_bool_yn {
+ my ($package, $attribute, %params) = @_;
+
+ no strict 'refs';
+ *{ $package . '::' . $attribute . '_as_bool_yn' } = sub {
+ my ($self) = @_;
+
+ if (@_ > 1) {
+ die 'not an accessor';
+ }
+
+ return !defined $self->$attribute ? ''
+ : $self->$attribute ? $::locale->text('Yes')
+ : $::locale->text('No');
+ }
+}
+
1;
__END__
+=encoding utf-8
+
=head1 NAME
SL::DB::Helper::Attr - attribute helpers
=head1 DESCRIPTION
+Makes attribute helpers.
+
=head1 FUNCTIONS
+see for yourself.
+
=head1 BUGS
+None yet.
+
=head1 AUTHOR
+Sven Schöling <s.schoeling@linet-services.de>
+
=cut