| Pangloss documentation | Contained in the Pangloss distribution. |
Pangloss::Object - base class for all Pangloss objects.
package Foo;
use base qw( Pangloss::Object );
# Pangloss::accessors is loaded for you:
use accessors qw( bar );
my $foo = Foo->new( @optional_args )->bar('baz');
$Pangloss::DEBUG{ Foo } = 1;
$Pangloss::DEBUG{ ALL } = 1;
$foo->emit( 'a message' );
Base class for Pangloss objects.
creates and returns a new object, if $obj->init( @args ) returns a true value.
does nothing by default. a false return value means initialization failed.
emits $msg if debugging is enabled for this object's class. can also be called as a class method.
hash of classes to enable debugging for, via emit(). If 'ALL' is set, debugging for all Pangloss classes is enabled.
Steve Purkis <spurkis@quiup.com>
Pangloss, Similar to OpenFrame::Object.
| Pangloss documentation | Contained in the Pangloss distribution. |
package Pangloss::Object; use strict; use warnings::register; our $VERSION = ((require Pangloss::Version), $Pangloss::VERSION)[1]; our $REVISION = (split(/ /, ' $Revision: 1.10 $ '))[2]; sub new { my $class = shift->class; my $self = bless {}, $class; $self->init(@_) || return; return $self; } sub init { my $self = shift; } sub emit { my $self = shift; my $mesg = shift; my $class = $self->class; my ($package, $filename, $line, $subroutine, $hasargs, $wantarray, $evaltext, $is_require, $hints, $bitmask) = caller( 1 ); $subroutine =~ s/.*:://; if ($Pangloss::DEBUG{ ALL } || $Pangloss::DEBUG{ $class }) { my $warn_str = "[$class\::$subroutine] $mesg"; $warn_str .= "\n" unless $mesg =~ /\n/; warn( $warn_str ); } return $self; } sub class { my $thing = shift; return ref($thing) || $thing; } 1; __END__ #------------------------------------------------------------------------------