Class-GAPI

 view release on metacpan or  search on metacpan

GAPI.html  view on Meta::CPAN

in the case of lunch but not in the case of pet.</p>
<p>
</p>
<hr />
<h1><a name="other_functions">OTHER FUNCTIONS</a></h1>
<p>Cloning is supported for Class::GAPI objects and any subordinate objects based on Class::GAPI
or that Inherit Class::GAPI. This includes Class::List objects. This is function is eval()d, so it 
will not crash if you have other stuff in their, just don't expect that other stuff copy.</p>
<pre>
        my $twin = $pet-&gt;clone(); # Make the FDA nervous</pre>
<p>The <code>overlay()</code> function allows one to execute a block of functions by passing hash.  This is equivilant 
to what happens when constructed with new(). This is typically usefull when you want to copy a hash 
into several objects as you might in a record table:</p>
<pre>
        package Guppy::School   ; 
        use Guppy               ; 
        our @ISA = qw(Guppy)    ; # We are derived from a Guppy, which is derived from a GAPI  
        our @Children = qw(Class::List::School) ; # $self-&gt;{'School'} is now an array</pre>
<pre>
        sub doSpawn { # Add a new Guppy Object
                my $self = shift                ;
                my $fish = Guppy-&gt;new(@_)       ; # Pass options pairs to the new fish 
                push @{$self-&gt;School()}, $fish  ; 
        }</pre>
<pre>
        sub fishGrow { # Add a block of options like so: fishGrow(2, foo =&gt; 'bar') ;  
                my $self = shift                ; 
                my $n = shift                   ; 
                $self-&gt;School-&gt;[$n]-&gt;overlay(@_); 
                return($fish)                   ;   
        }
        1 ;</pre>
<p>The <code>warn_self()</code> function is pretty much what it sounds like. You can call it at any level with 
a tree of nested GAPI and it will produce a table of the object as a warning. Obviously this 
handy for debugging:</p>
<pre>
        $self-&gt;warn_self() ;
        $self-&gt;Foo-&gt;Bar-&gt;warn_self() ;</pre>
<p>

README  view on Meta::CPAN

in the case of lunch but not in the case of pet. 

=head1 OTHER FUNCTIONS

Cloning is supported for Class::GAPI objects and any subordinate objects based on Class::GAPI
or that Inherit Class::GAPI. This includes Class::List objects. This is function is eval()d, so it 
will not crash if you have other stuff in their, just don't expect that other stuff copy. 

	my $twin = $pet->clone(); # Make the FDA nervous 

The overlay() function allows one to execute a block of functions by passing hash.  This is equivilant 
to what happens when constructed with new(). This is typically usefull when you want to copy a hash 
into several objects as you might in a record table:

	package Guppy::School	; 
	use Guppy		; 
	our @ISA = qw(Guppy)	; # We are derived from a Guppy, which is derived from a GAPI  
	our @Children = qw(Class::List::School) ; # $self->{'School'} is now an array

	sub doSpawn { # Add a new Guppy Object
		my $self = shift		;
		my $fish = Guppy->new(@_)	; # Pass options pairs to the new fish 
		push @{$self->School()}, $fish  ; 
	}

	sub fishGrow { # Add a block of options like so: fishGrow(2, foo => 'bar') ;  
		my $self = shift		; 
		my $n = shift			; 
		$self->School->[$n]->overlay(@_); 
		return($fish)			;   
	}
	1 ;

The warn_self() function is pretty much what it sounds like. You can call it at any level with 
a tree of nested GAPI and it will produce a table of the object as a warning. Obviously this 
handy for debugging: 

	$self->warn_self() ;
	$self->Foo->Bar->warn_self() ; 

lib/Class/GAPI.pm  view on Meta::CPAN

	my $val = shift ; 
	if (ref($val)) {
		foreach('SCALAR','ARRAY','HASH','CODE','GLOB','REF','LVALUE','IO::Handle') {
			if ($val =~ $_ ) { return 0 ; }
		}
		return 1 ; 
	} 
	return 0 ; 
}  

sub overlay {  # Convert a hash into a series of function calls.
	my $self = shift 		          ;
	return undef if  scalar(@_) % 2   ;
	my %pairs = @_ 			    ;
 
	while(my ($k, $v) = each %pairs) {
		my $block = join "", ( '$self->', $k, '(', '$v', ');' ) ;
		eval($block)          	 	    ;
		if ($@) {
			my $class = ref($self) 		    ; 
			warn ("$class is executing $block and throwing:\n $@\n XXXXXXXXXXXXXXXXXXX") ;

lib/Class/GAPI.pm  view on Meta::CPAN

in the case of lunch but not in the case of pet. 

=head1 OTHER FUNCTIONS

Cloning is supported for Class::GAPI objects and any subordinate objects based on Class::GAPI
or that Inherit Class::GAPI. This includes Class::List objects. This is function is eval()d, so it 
will not crash if you have other stuff in their, just don't expect that other stuff copy. 

	my $twin = $pet->clone(); # Make the FDA nervous 

The overlay() function allows one to execute a block of functions by passing hash.  This is equivilant 
to what happens when constructed with new(). This is typically usefull when you want to copy a hash 
into several objects as you might in a record table:

	package Guppy::School	; 
	use Guppy		; 
	our @ISA = qw(Guppy)	; # We are derived from a Guppy, which is derived from a GAPI  
	our @Children = qw(Class::List::School) ; # $self->{'School'} is now an array

	sub doSpawn { # Add a new Guppy Object
		my $self = shift		;
		my $fish = Guppy->new(@_)	; # Pass options pairs to the new fish 
		push @{$self->School()}, $fish  ; 
	}

	sub fishGrow { # Add a block of options like so: fishGrow(2, foo => 'bar') ;  
		my $self = shift		; 
		my $n = shift			; 
		$self->School->[$n]->overlay(@_); 
		return($fish)			;   
	}
	1 ;

The warn_self() function is pretty much what it sounds like. You can call it at any level with 
a tree of nested GAPI and it will produce a table of the object as a warning. Obviously this 
handy for debugging: 

	$self->warn_self() ;
	$self->Foo->Bar->warn_self() ; 



( run in 2.637 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )