Skip to content

Instantly share code, notes, and snippets.

@opendevnet
Created June 24, 2016 20:48
Show Gist options
  • Save opendevnet/1bce50b1682b53333171f6dd0cb14dd7 to your computer and use it in GitHub Desktop.
Save opendevnet/1bce50b1682b53333171f6dd0cb14dd7 to your computer and use it in GitHub Desktop.
package Surfz ;
use Function::Parameters ;
use base 'Sub::Attributes';
fun new :ClassMethod {
my $class = shift;
my $self = {};
bless $self, $class;
return $self;
}
# croak if not called as a class method
method rocks :ClassMethod {
print "the surf rox\n";
}
method flow :Method {
print "Ok better now some flow\n";
}
fun wheee () {
print "This sub is fun!!\n";
}
sub whee {
print "Some fun as a sub!!\n";
}
package main;
Surfz->rocks() ;
# Surfz::rocks(); fatal unless s/croak/carp/ in Sub/Atrributes.pm
Surfz::whee() ;
Surfz::wheee() ;
Surfz->wheee() ;
print "\ninstances coming up\n\n";
my $surf = Surfz->new() ;
# $surf->rocks();
$surf->flow(); # Surfz::flow() and Surfz->flow() will fail
$surf->whee() ;
$surf->wheee() ;
#
use DDP;
$subs = $surf->sub_attributes();
p $subs;
@opendevnet
Copy link
Author

the surf rox
Some fun as a sub!!
This sub is fun!!
This sub is fun!!

instances coming up

Ok better now some flow
Some fun as a sub!!
This sub is fun!!
\ {
    flow    [
        [0] "Method"
    ],
    new     [
        [0] "ClassMethod"
    ],
    rocks   [
        [0] "ClassMethod"
    ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment