GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Role::HasMessage::Errf(3) User Contributed Perl Documentation Role::HasMessage::Errf(3)

Role::HasMessage::Errf - a thing with a String::Errf-powered message

version 0.006

In your class...

  package Errfy;
  use Moose;

  with 'Role::HasMessage::Errf';

  has payload => (
    is  => 'ro',
    isa => 'HashRef',
    required => 1,
  );

Then...

  my $thing = Errfy->new({
    message => "%{error_count;error}n encountered at %{when}t",
    payload => {
      error_count => 2,
      when        => time,
    },
  });

  # prints: 2 errors encountered at 2010-10-20 19:23:42
  print $thing->message;

Role::HasMessage::Errf is an implementation of Role::HasMessage that uses String::Errf to format "sprintf"-like message strings. It adds a "message_fmt" attribute, initialized by the "message" argument. The value should be a String::Errf format string.

When the provided "message" method is called, it will fill in the format string with the hashref returned by calling the "payload" method, which must be implemented by the including class.

Role::HasMessage::Errf is a parameterized role. The "default" parameter lets you set a default format string or callback. The "lazy" parameter sets whether or not the "message_fmt" attribute is lazy. Setting it lazy will require that a default is provided.

Ricardo Signes <rjbs@cpan.org>

This software is copyright (c) 2013 by Ricardo Signes.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

2013-10-16 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.