Beanstalk::Stats - Class to represent stats results from the beanstalk server


Beanstalk-Client documentation Contained in the Beanstalk-Client distribution.

Index


Code Index:

NAME

Top

Beanstalk::Stats - Class to represent stats results from the beanstalk server

SYNOPSIS

Top

  my $client = Beanstalk::Client->new;

  my $stats = $client->stats;

  print $stats->uptime,"\n"

DESCRIPTION

Top

Simple class to allow method access to hash of stats returned by stats, stats_job and stats_tube commands

See Beanstalk::Client for the methods available based on the command used

SEE ALSO

Top

Beanstalk::Client

AUTHOR

Top

Graham Barr <gbarr@pobox.com>

COPYRIGHT

Top


Beanstalk-Client documentation Contained in the Beanstalk-Client distribution.

package Beanstalk::Stats;

use strict;
use warnings;

use Carp ();

our $AUTOLOAD;
our $VERSION = "1.06";

sub new {
  my $proto = shift;
  my $href = shift;
  bless $href, $proto;
}

sub DESTROY { } 

sub AUTOLOAD {
  (my $method = $AUTOLOAD) =~ s/.*:://;
  (my $field  = $method)   =~ tr/_/-/;

  unless (ref($_[0]) and exists $_[0]->{$field}) {
    my $proto = ref($_[0]) || $_[0];
    Carp::croak(qq{Can't locate object method "$method" via package "$proto"});
  }
  no strict 'refs';
  *{$AUTOLOAD} = sub {
    my $self = shift;
    unless (ref($self) and exists $self->{$field}) {
      my $proto = ref($self) || $self;
      Carp::croak(qq{Can't locate object method "$method" via package "$proto"});
    }
    $self->{$field};
  };

  goto &$AUTOLOAD;
}

1;

__END__