NAME

Net::SolarWinds::Result - Result class

SYNOPSIS

use Net::SolarWinds::Result;


my $res=new_true Net::SolarWinds::Result('some data');

print $res->get_data if($res);

$res->set_false('some error');

die $res unless $res;

DESCRIPTION

This package acts as a general result class, it allows for returing of state and objects within a single context using encapsulation.

OVERLOADED METHODS

The following methods have been overloaded

bool
  # an instance when set to false will test as false
'""'
  # an instance when called in a string context will return
  # the error message given if any

OO Methods

  • Objec Construcotr(s)

    Multiple objec constructors have been provided.

    new Net::SolarWinds::Result(
      bool=>0|1,
        # true false state
      data=>'string'|ref,
        # data for the $self->get_data command
      msg=>'human readable string',
        # message for the '""' op or $self->get_msg
      extra=>'string'|ref
        # extra paylod ( helpful in debugging )
    );
    new_true Net::SolarWinds::Result($data,$extra)
    
     Returns a new true object
    new_false Net::SolarWinds::Result($msg,$extra)
    
    Returns a new false instance
    new_error Net::SolarWinds::Result($msg,$extra);
    
    Returns a new false instance
    new_ok Net::SolarWinds::Result($data,$extra);
    
    Returns a new true instance
  • if($self->is_ok) {...}

    Returns true if the instance is true.

  • my $data=$self->get_data

    Returns the object from the data field

  • my $extra=$self->get_extra

    Returns the object from the extra field

  • $self->set_true($data,$extra)

    Sets the current argument to true, overloading the current $data and $extra objects

  • my $error=$self->get_error

    Returns the current msg value

  • my $msg=$self->get_msg

    Returns the current msg value, if undef it returns ''

  • $self->set_false($msg,$extra)

    Sets the object to a false state, this will destroy an objects in the $data field.

  • $self->set_boolean_cb(sub { 0 } );

    Special case: allows for setting call backs for the boolean state.

  • $self->DESTROY()

    Used for cleaning up the object internals

AUTHOR

Michael Shipper