Permalink
Browse files

add format_string

  • Loading branch information...
1 parent 2d47783 commit 21f79c7b02c17c24a791711e6810856db88016d9 @rjbs committed Jan 13, 2011
Showing with 19 additions and 1 deletion.
  1. +1 −0 Changes
  2. +18 −1 lib/String/Flogger.pm
View
@@ -1,6 +1,7 @@
Revision history for String-Flogger
{{$NEXT}}
+ add format_string method for subclassing
1.101240 2010-05-04 16:25:47 America/New_York
better stringification of unblessed scalar refs (to ref(...))
View
@@ -38,6 +38,18 @@ The above will output:
while avoiding sprintfiness, if needed
+=method flag
+
+This method is described in the synopsis.
+
+=method format_string
+
+ $flogger->format_string($fmt, \@input);
+
+This method is used to take the formatted arguments for a format string (when
+C<flog> is passed an arrayref) and turn it into a string. By default, it just
+uses C<L<perlfunc/sprintf>>.
+
=cut
sub _encrefs {
@@ -83,10 +95,15 @@ sub flog {
if (_ARRAYLIKE($input)) {
my ($fmt, @data) = @$input;
- return sprintf $fmt, $class->_encrefs(\@data);
+ return $class->format_string($fmt, $class->_encrefs(\@data));
}
return $class->_encrefs([ $input ]);
}
+sub format_string {
+ my ($self, $fmt, @input) = @_;
+ sprintf $fmt, @input;
+}
+
1;

0 comments on commit 21f79c7

Please sign in to comment.