class
Sponsored Links
Sponsored Links
Secleted [ 0 ] software to compare
Results 1 - 15 of about 2607
Class::AbstractLogic 0.01_01
Class::AbstractLogic is a Perl module to handle Logic Abstractions. more>>
Class::AbstractLogic is a Perl module to handle Logic Abstractions.
SYNOPSIS
# the logic class definition
package My::Logic::Foo;
use Class::AbstractLogic-base;
# a logic action
action add,
needs [qw(a b)],
verify { a => sub { /^d+$/ }, b => sub { /^d+$/ } },
sub { $_{a} + $_{b} };
1;
...
# logic module manager creation
use Class::AbstractLogic;
my $calm = Class::AbstractLogic::Manager->new;
# loading a logic class
$calm->load_logic(Foo => My::Logic::Foo);
# requesting a result from a logic method
my $result = $calm->logic(Foo)->add(a => 11, b => 12);
# $result will be false if an exception was caught
if ($result) {
print result was . $result->value . "n";
}
else {
print exception raised: . $result->key . "n";
print error message: . $result->error . "n";
}
<<lessSYNOPSIS
# the logic class definition
package My::Logic::Foo;
use Class::AbstractLogic-base;
# a logic action
action add,
needs [qw(a b)],
verify { a => sub { /^d+$/ }, b => sub { /^d+$/ } },
sub { $_{a} + $_{b} };
1;
...
# logic module manager creation
use Class::AbstractLogic;
my $calm = Class::AbstractLogic::Manager->new;
# loading a logic class
$calm->load_logic(Foo => My::Logic::Foo);
# requesting a result from a logic method
my $result = $calm->logic(Foo)->add(a => 11, b => 12);
# $result will be false if an exception was caught
if ($result) {
print result was . $result->value . "n";
}
else {
print exception raised: . $result->key . "n";
print error message: . $result->error . "n";
}
Download (0.016MB)
Added: 2007-08-01 License: Perl Artistic License Price:
814 downloads
Class::Generate 1.09
Class::Generate is a Perl module that can generate Perl class hierarchies. more>>
Class::Generate is a Perl module that can generate Perl class hierarchies.
SYNOPSIS
use Class::Generate qw(class subclass delete_class);
# Declare class Class_Name, with the following types of members:
class
Class_Name => [
s => $, # scalar
a => @, # array
h => %, # hash
c => Class, # Class
c_a => @Class, # array of Class
c_h => %Class, # hash of Class
&m => body, # method
];
# Allocate an instance of class_name, with members initialized to the
# given values (pass arrays and hashes using references).
$obj = Class_Name->new ( s => scalar,
a => [ values ],
h => { key1 => v1, ... },
c => Class->new,
c_a => [ Class->new, ... ],
c_h => [ key1 => Class->new, ... ] );
# Scalar type accessor:
$obj->s($value); # Assign $value to member s.
$member_value = $obj->s; # Access members value.
# (Class) Array type accessor:
$obj->a([value1, value2, ...]); # Assign whole array to member.
$obj->a(2, $value); # Assign $value to array member 2.
$obj->add_a($value); # Append $value to end of array.
@a = $obj->a; # Access whole array.
$ary_member_value = $obj->a(2); # Access array member 2.
$s = $obj->a_size; # Return size of array.
$value = $obj->last_a; # Return last element of array.
# (Class) Hash type accessor:
$obj->h({ k_1=>v1, ..., k_n=>v_n }) # Assign whole hash to member.
$obj->h($key, $value); # Assign $value to hash member $key.
%hash = $obj->h; # Access whole hash.
$hash_member_value = $obj->h($key); # Access hash member value $key.
$obj->delete_h($key); # Delete slot occupied by $key.
@keys = $obj->h_keys; # Access keys of member h.
@values = $obj->h_values; # Access values of member h.
$another = $obj->copy; # Copy an object.
if ( $obj->equals($another) ) { ... } # Test equality.
subclass s => [ ], -parent => class_name;
The Class::Generate package exports functions that take as arguments a class specification and create from these specifications a Perl 5 class. The specification language allows many object-oriented constructs: typed members, inheritance, private members, required members, default values, object methods, class methods, class variables, and more.
CPAN contains similar packages. Why another? Because object-oriented programming, especially in a dynamic language like Perl, is a complicated endeavor. I wanted a package that would work very hard to catch the errors you (well, I anyway) commonly make. I wanted a package that could help me enforce the contract of object-oriented programming. I also wanted it to get out of my way when I asked.
<<lessSYNOPSIS
use Class::Generate qw(class subclass delete_class);
# Declare class Class_Name, with the following types of members:
class
Class_Name => [
s => $, # scalar
a => @, # array
h => %, # hash
c => Class, # Class
c_a => @Class, # array of Class
c_h => %Class, # hash of Class
&m => body, # method
];
# Allocate an instance of class_name, with members initialized to the
# given values (pass arrays and hashes using references).
$obj = Class_Name->new ( s => scalar,
a => [ values ],
h => { key1 => v1, ... },
c => Class->new,
c_a => [ Class->new, ... ],
c_h => [ key1 => Class->new, ... ] );
# Scalar type accessor:
$obj->s($value); # Assign $value to member s.
$member_value = $obj->s; # Access members value.
# (Class) Array type accessor:
$obj->a([value1, value2, ...]); # Assign whole array to member.
$obj->a(2, $value); # Assign $value to array member 2.
$obj->add_a($value); # Append $value to end of array.
@a = $obj->a; # Access whole array.
$ary_member_value = $obj->a(2); # Access array member 2.
$s = $obj->a_size; # Return size of array.
$value = $obj->last_a; # Return last element of array.
# (Class) Hash type accessor:
$obj->h({ k_1=>v1, ..., k_n=>v_n }) # Assign whole hash to member.
$obj->h($key, $value); # Assign $value to hash member $key.
%hash = $obj->h; # Access whole hash.
$hash_member_value = $obj->h($key); # Access hash member value $key.
$obj->delete_h($key); # Delete slot occupied by $key.
@keys = $obj->h_keys; # Access keys of member h.
@values = $obj->h_values; # Access values of member h.
$another = $obj->copy; # Copy an object.
if ( $obj->equals($another) ) { ... } # Test equality.
subclass s => [ ], -parent => class_name;
The Class::Generate package exports functions that take as arguments a class specification and create from these specifications a Perl 5 class. The specification language allows many object-oriented constructs: typed members, inheritance, private members, required members, default values, object methods, class methods, class variables, and more.
CPAN contains similar packages. Why another? Because object-oriented programming, especially in a dynamic language like Perl, is a complicated endeavor. I wanted a package that would work very hard to catch the errors you (well, I anyway) commonly make. I wanted a package that could help me enforce the contract of object-oriented programming. I also wanted it to get out of my way when I asked.
Download (0.052MB)
Added: 2007-07-31 License: Perl Artistic License Price:
815 downloads
Class::Prototyped::Mixin 2.4
Class::Prototyped::Mixin Perl module contains Mixin Support for Class::Prototyped. more>>
Class::Prototyped::Mixin Perl module contains Mixin Support for Class::Prototyped.
SYNOPSIS
Usage one: whip up a class and toss it in a scalar
package HelloWorld;
sub hello {
my ($self, $age) = @_;
return "Hello World! I am $age years old"
}
package HelloWorld::Uppercase;
use base qw(Class::Prototyped);
__PACKAGE__->reflect->addSlot(
[qw(hello superable)] => sub {
my $self = shift;
my $ret = $self->reflect->super(hello, @_);
uc $ret
}
);
package HelloWorld::Bold;
use base qw(Class::Prototyped);
__PACKAGE__->reflect->addSlot(
[qw(hello superable)] => sub {
my $self = shift;
my $ret = $self->reflect->super(hello, @_);
"< b >$ret< /b >";
}
);
package HelloWorld::Italic;
use base qw(Class::Prototyped);
__PACKAGE__->reflect->addSlot(
[qw(hello superable)] => sub {
my $self = shift;
my $ret = $self->reflect->super(hello, @_);
"< i >$ret< /i >";
}
);
# script.pl - now the whipping begins
use Class::Prototyped::Mixin qw(mixin);
my $runtime = mixin(
HelloWorld => HelloWorld::Uppercase, HelloWorld::Italic
);
print $runtime->hello(74);
< i >HELLO WORLD! I AM 74 YEARS OLD< /i >
Usage two: create hierarchy and install in a Class::Prototyped package
package CompileTime;
use Class::Prototyped::Mixin qw(mixin);
my $uclass = mixin(
HelloWorld => HelloWorld::Uppercase, HelloWorld::Bold
);
__PACKAGE__->reflect->addSlot(
* => $uclass
);
# script.pl
use CompileTime;
print CompileTime->hello(88);
< b >HELLO WORLD! I AM 88 YEARS OLD< /b >
<<lessSYNOPSIS
Usage one: whip up a class and toss it in a scalar
package HelloWorld;
sub hello {
my ($self, $age) = @_;
return "Hello World! I am $age years old"
}
package HelloWorld::Uppercase;
use base qw(Class::Prototyped);
__PACKAGE__->reflect->addSlot(
[qw(hello superable)] => sub {
my $self = shift;
my $ret = $self->reflect->super(hello, @_);
uc $ret
}
);
package HelloWorld::Bold;
use base qw(Class::Prototyped);
__PACKAGE__->reflect->addSlot(
[qw(hello superable)] => sub {
my $self = shift;
my $ret = $self->reflect->super(hello, @_);
"< b >$ret< /b >";
}
);
package HelloWorld::Italic;
use base qw(Class::Prototyped);
__PACKAGE__->reflect->addSlot(
[qw(hello superable)] => sub {
my $self = shift;
my $ret = $self->reflect->super(hello, @_);
"< i >$ret< /i >";
}
);
# script.pl - now the whipping begins
use Class::Prototyped::Mixin qw(mixin);
my $runtime = mixin(
HelloWorld => HelloWorld::Uppercase, HelloWorld::Italic
);
print $runtime->hello(74);
< i >HELLO WORLD! I AM 74 YEARS OLD< /i >
Usage two: create hierarchy and install in a Class::Prototyped package
package CompileTime;
use Class::Prototyped::Mixin qw(mixin);
my $uclass = mixin(
HelloWorld => HelloWorld::Uppercase, HelloWorld::Bold
);
__PACKAGE__->reflect->addSlot(
* => $uclass
);
# script.pl
use CompileTime;
print CompileTime->hello(88);
< b >HELLO WORLD! I AM 88 YEARS OLD< /b >
Download (0.011MB)
Added: 2007-07-31 License: Perl Artistic License Price:
815 downloads
Class::Simple 0.07
Class::Simple is a simple Object-Oriented Base Class. more>>
Class::Simple is a simple Object-Oriented Base Class.
SYNOPSIS
package Foo:
use base qw(Class::Simple);
BEGIN
{
Foo->privatize(qw(attrib1 attrib2)); # ...or not.
}
my $obj = Foo->new();
$obj->attrib(1); # The same as...
$obj->set_attrib(1); # ...this.
my $var = $obj->get_attrib(); # The same as...
$var = $obj->attrib; # ...this.
$obj->raise_attrib(); # The same as...
$obj->set_attrib(1); # ...this.
$obj->clear_attrib(); # The same as...
$obj->set_attrib(undef); # ...this
$obj->attrib(undef); # ...and this.
$obj->readonly_attrib(4);
sub foo
{
my $self = shift;
my $value = shift;
$self->_foo($value);
do_other_things(@_);
...
}
my $str = $obj->DUMP;
my $new_obj = Foo->new();
$new_obj->SLURP($str);
sub BUILD
{
my $self = shift;
# Various initializations
}
There are plenty of others that are much more thorough and whatnot but sometimes I want something simple so I can get just going (no doubt because I am a simple guy) so I use this.
What do I mean by simple? First off, I dont want to have to list out all my methods beforehand. I just want to use them (Yeah, yeah, it doesnt catch typos--thats what testing and Class::Std are for :-). Next, I want to be able to call my methods by $obj->foo(1) or $obj->set_foo(1), by $obj->foo() or $obj->get_foo(). Dont tell ME I have to use get_ and set_ (I would just override that restriction in Class::Std anyway). Simple!
I did want some neat features, though, so these are inside-out objects (meaning the object isnt simply a hash so you cant just go in and muck with attributes outside of methods), privatization of methods is supported, as is serialization out and back in again.
<<lessSYNOPSIS
package Foo:
use base qw(Class::Simple);
BEGIN
{
Foo->privatize(qw(attrib1 attrib2)); # ...or not.
}
my $obj = Foo->new();
$obj->attrib(1); # The same as...
$obj->set_attrib(1); # ...this.
my $var = $obj->get_attrib(); # The same as...
$var = $obj->attrib; # ...this.
$obj->raise_attrib(); # The same as...
$obj->set_attrib(1); # ...this.
$obj->clear_attrib(); # The same as...
$obj->set_attrib(undef); # ...this
$obj->attrib(undef); # ...and this.
$obj->readonly_attrib(4);
sub foo
{
my $self = shift;
my $value = shift;
$self->_foo($value);
do_other_things(@_);
...
}
my $str = $obj->DUMP;
my $new_obj = Foo->new();
$new_obj->SLURP($str);
sub BUILD
{
my $self = shift;
# Various initializations
}
There are plenty of others that are much more thorough and whatnot but sometimes I want something simple so I can get just going (no doubt because I am a simple guy) so I use this.
What do I mean by simple? First off, I dont want to have to list out all my methods beforehand. I just want to use them (Yeah, yeah, it doesnt catch typos--thats what testing and Class::Std are for :-). Next, I want to be able to call my methods by $obj->foo(1) or $obj->set_foo(1), by $obj->foo() or $obj->get_foo(). Dont tell ME I have to use get_ and set_ (I would just override that restriction in Class::Std anyway). Simple!
I did want some neat features, though, so these are inside-out objects (meaning the object isnt simply a hash so you cant just go in and muck with attributes outside of methods), privatization of methods is supported, as is serialization out and back in again.
Download (0.009MB)
Added: 2007-07-31 License: Perl Artistic License Price:
815 downloads
Class::Bits 0.05
Class::Bits is a Perl module with class wrappers around bit vectors. more>>
Class::Bits is a Perl module with class wrappers around bit vectors.
SYNOPSIS
package MyClass;
use Class::Bits;
make_bits( a => 4, # 0..15
b => 1, # 0..1
c => 1, # 0..1
d => 2, # 0..3
e => s4 # -8..7
f => s1 # -1..0
);
package;
$o=MyClass->new(a=>12, d=>2);
print "o->b is ", $o->b, "n";
print "bit vector is ", unpack("h*", $$o), "n";
$o2=$o->new();
$o3=MyClass->new($string);
ABSTRACT
Class::Bits creates class wrappers around bit vectors.
Class::Bits defines classes using bit vectors as storage.
Object attributes are stored in bit fields inside the bit vector. Bit field sizes have to be powers of 2 (1, 2, 4, 8, 16 or 32).
There is a class constructor subroutine:
make_bits( field1 => size1, field2 => size2, ...)
exports in the calling package a ctor, accessor methods, some utility methods and some constants:
Sizes can be prefixed by s or u to define signedness of the field. Default is unsigned.
$class->new()
creates a new object with all zeros.
$class->new($bitvector)
creates a new object over $bitvector.
$class->new(%fields)
creates a new object and initializes its fields with the values in %fields.
$obj->new()
clones an object.
$obj->$field()
$obj->$field($value)
gets or sets the value of the bit field $field inside the bit vector.
$class->length
$obj->lenght
returns the size in bits of the bit vector used for storage.
$class->keys
$obj->keys
returns an array with the names of the object attributes
$obj->as_hash
returns a flatten hash with the object attributes, i.e.:
my %values=$obj->as_hash;
%INDEX
hash with offsets as used by vec perl operator (to get an offset in bits, the value has to be multiplied by the corresponding bit field size).
%SIZES
hash with bit field sizes in bits.
%SIGNED
hash with signedness of the fields
Bit fields are packed in the bit vector in the order specified as arguments to make_bits.
Bit fields are padded inside the bit vector, i.e. a class created like
make_bits(A=>1, B=>2, C=>1, D=>4, E=>8, F=>16);
will have the layout
AxBBCxxx DDDDxxxx EEEEEEEE xxxxxxxx FFFFFFFF FFFFFFFF
<<lessSYNOPSIS
package MyClass;
use Class::Bits;
make_bits( a => 4, # 0..15
b => 1, # 0..1
c => 1, # 0..1
d => 2, # 0..3
e => s4 # -8..7
f => s1 # -1..0
);
package;
$o=MyClass->new(a=>12, d=>2);
print "o->b is ", $o->b, "n";
print "bit vector is ", unpack("h*", $$o), "n";
$o2=$o->new();
$o3=MyClass->new($string);
ABSTRACT
Class::Bits creates class wrappers around bit vectors.
Class::Bits defines classes using bit vectors as storage.
Object attributes are stored in bit fields inside the bit vector. Bit field sizes have to be powers of 2 (1, 2, 4, 8, 16 or 32).
There is a class constructor subroutine:
make_bits( field1 => size1, field2 => size2, ...)
exports in the calling package a ctor, accessor methods, some utility methods and some constants:
Sizes can be prefixed by s or u to define signedness of the field. Default is unsigned.
$class->new()
creates a new object with all zeros.
$class->new($bitvector)
creates a new object over $bitvector.
$class->new(%fields)
creates a new object and initializes its fields with the values in %fields.
$obj->new()
clones an object.
$obj->$field()
$obj->$field($value)
gets or sets the value of the bit field $field inside the bit vector.
$class->length
$obj->lenght
returns the size in bits of the bit vector used for storage.
$class->keys
$obj->keys
returns an array with the names of the object attributes
$obj->as_hash
returns a flatten hash with the object attributes, i.e.:
my %values=$obj->as_hash;
%INDEX
hash with offsets as used by vec perl operator (to get an offset in bits, the value has to be multiplied by the corresponding bit field size).
%SIZES
hash with bit field sizes in bits.
%SIGNED
hash with signedness of the fields
Bit fields are packed in the bit vector in the order specified as arguments to make_bits.
Bit fields are padded inside the bit vector, i.e. a class created like
make_bits(A=>1, B=>2, C=>1, D=>4, E=>8, F=>16);
will have the layout
AxBBCxxx DDDDxxxx EEEEEEEE xxxxxxxx FFFFFFFF FFFFFFFF
Download (0.004MB)
Added: 2007-07-30 License: Perl Artistic License Price:
816 downloads
Class::DispatchToAll 0.11
Class::DispatchToAll Perl module can dispatch a method call to all inherited methods. more>>
Class::DispatchToAll Perl module can dispatch a method call to all inherited methods.
SYNOPSIS
package My::Class;
our @ISA=qw(SomeClass SomeOtherClass More::Classes);
use Class::DispatchToAll qw(dispatch_to_all);
my $self=bless {},My::Class # not a proper constructor, I know..
# this calls some_method in all Classes My::Class inherits from
# and all classes those classes inherit from, and all ... you get
# the point.
$self->dispatch_to_all(some_method);
# saves all return values from all calls in an array
my @returns=$self->dispatch_to_all(some_method);
See the Docs of Damian Conways Module Class::Delegation for a good introduction about Dispatching vs. Inheritance.
Class::DispatchToAll enables you to call all instantances of a method in your inheritance tree (or labyrinth..).
The standard Perl behaviour is to call only the lefternmost instance it can fing doing a depth first traversial.
Imagine the following class structure:
C
/
A B C::C
/ /
A::A D
/
My::Class
Perl will try to find a method in this mess in this order:
My::Class -> A::A -> A -> B -> D -> B -> C::C -> C
(Note that it will look twice in B because B is a parent of both A::A and D))
As soon as Perl finds the method somewhere, it will short-circuit out of its search and invoke the method.
And that is exactly the behaviour Class::DispatchToAll changes.
If you use dispatch_to_all (provided by Class::DispatchToAll) to call your method, Perl will look in all of the aforementioned packages and run all the methods it can find. It will even collect all the return values and return them to you as an array, if you want it too.
<<lessSYNOPSIS
package My::Class;
our @ISA=qw(SomeClass SomeOtherClass More::Classes);
use Class::DispatchToAll qw(dispatch_to_all);
my $self=bless {},My::Class # not a proper constructor, I know..
# this calls some_method in all Classes My::Class inherits from
# and all classes those classes inherit from, and all ... you get
# the point.
$self->dispatch_to_all(some_method);
# saves all return values from all calls in an array
my @returns=$self->dispatch_to_all(some_method);
See the Docs of Damian Conways Module Class::Delegation for a good introduction about Dispatching vs. Inheritance.
Class::DispatchToAll enables you to call all instantances of a method in your inheritance tree (or labyrinth..).
The standard Perl behaviour is to call only the lefternmost instance it can fing doing a depth first traversial.
Imagine the following class structure:
C
/
A B C::C
/ /
A::A D
/
My::Class
Perl will try to find a method in this mess in this order:
My::Class -> A::A -> A -> B -> D -> B -> C::C -> C
(Note that it will look twice in B because B is a parent of both A::A and D))
As soon as Perl finds the method somewhere, it will short-circuit out of its search and invoke the method.
And that is exactly the behaviour Class::DispatchToAll changes.
If you use dispatch_to_all (provided by Class::DispatchToAll) to call your method, Perl will look in all of the aforementioned packages and run all the methods it can find. It will even collect all the return values and return them to you as an array, if you want it too.
Download (0.005MB)
Added: 2007-07-21 License: Perl Artistic License Price:
825 downloads
Class::Classless 1.35
Class::Classless is a Perl framework for classless OOP. more>>
Class::Classless is a Perl framework for classless OOP.
SYNOPSIS
use strict;
use Class::Classless;
my $ob1 = $Class::Classless::ROOT->clone;
$ob1->{NAME} = Ob1;
$ob1->{stuff} = 123;
$ob1->{Thing} = 789;
my $ob2 = $ob1->clone;
$ob2->{NAME} = Ob2;
printf "ob1 stuff: n", $ob1->{stuff};
printf "ob2 stuff: n", $ob2->{stuff};
printf "ob1 Thing: n", $ob1->{Thing};
printf "ob2 Thing: n", $ob2->{Thing};
$ob1->{METHODS}{zaz} = sub {
print "Zaz! on ", $_[0]{NAME}, "n";
};
$ob1->zaz;
$ob2->zaz;
$ob1->EXAMINE;
$ob2->EXAMINE;
This prints the following:
ob1 stuff: < 123 >
ob2 stuff: < 123 >
ob1 Thing: < 789 >
ob2 Thing: < >
Zaz! on Ob1
Zaz! on Ob2
< Class::Classless::X=HASH(0x200236f4) >
stuff, 123,
NAME, Ob1,
Thing, 789,
METHODS, { zaz, CODE(0x20068360) },
PARENTS, [ ROOT ],
< Class::Classless::X=HASH(0x2002cb48) >
stuff, 123,
NAME, Ob2,
METHODS, { },
PARENTS, [ Ob1 ],
In class-based OOP frameworks, methods are applicable to objects by virtue of objects belonging to classes that either provide those methods, or inherit them from classes that do.
In classless OOP frameworks (AKA delegation-and-prototypes frameworks), what methods an object is capable of is basically an attribute of that object. That is, in Perl terms: instead of methods being entries in the symbol table of the package/class the object belongs to, they are entries in a hash table inside the object. Inheritance is implemented not by having classes inheriting from other classes (via ISA lists), but by having objects inherit from other objects (via PARENTS lists).
In class-based OOP frameworks, you get new objects by calling constructors. In a classless framework, you get new objects by copying ("cloning") an existing object -- and the new clone becomes a child (inheritor) of the original object. (Where do you get the one original object? The language provides one, which has no parents, and which contains some general purpose methods like "clone".)
<<lessSYNOPSIS
use strict;
use Class::Classless;
my $ob1 = $Class::Classless::ROOT->clone;
$ob1->{NAME} = Ob1;
$ob1->{stuff} = 123;
$ob1->{Thing} = 789;
my $ob2 = $ob1->clone;
$ob2->{NAME} = Ob2;
printf "ob1 stuff: n", $ob1->{stuff};
printf "ob2 stuff: n", $ob2->{stuff};
printf "ob1 Thing: n", $ob1->{Thing};
printf "ob2 Thing: n", $ob2->{Thing};
$ob1->{METHODS}{zaz} = sub {
print "Zaz! on ", $_[0]{NAME}, "n";
};
$ob1->zaz;
$ob2->zaz;
$ob1->EXAMINE;
$ob2->EXAMINE;
This prints the following:
ob1 stuff: < 123 >
ob2 stuff: < 123 >
ob1 Thing: < 789 >
ob2 Thing: < >
Zaz! on Ob1
Zaz! on Ob2
< Class::Classless::X=HASH(0x200236f4) >
stuff, 123,
NAME, Ob1,
Thing, 789,
METHODS, { zaz, CODE(0x20068360) },
PARENTS, [ ROOT ],
< Class::Classless::X=HASH(0x2002cb48) >
stuff, 123,
NAME, Ob2,
METHODS, { },
PARENTS, [ Ob1 ],
In class-based OOP frameworks, methods are applicable to objects by virtue of objects belonging to classes that either provide those methods, or inherit them from classes that do.
In classless OOP frameworks (AKA delegation-and-prototypes frameworks), what methods an object is capable of is basically an attribute of that object. That is, in Perl terms: instead of methods being entries in the symbol table of the package/class the object belongs to, they are entries in a hash table inside the object. Inheritance is implemented not by having classes inheriting from other classes (via ISA lists), but by having objects inherit from other objects (via PARENTS lists).
In class-based OOP frameworks, you get new objects by calling constructors. In a classless framework, you get new objects by copying ("cloning") an existing object -- and the new clone becomes a child (inheritor) of the original object. (Where do you get the one original object? The language provides one, which has no parents, and which contains some general purpose methods like "clone".)
Download (0.023MB)
Added: 2007-07-19 License: Perl Artistic License Price:
827 downloads
Class::IntrospectionMethods::Catalog 1.003
Class::IntrospectionMethods::Catalog can manage catalogs from IntrospectionMethods. more>>
Class::IntrospectionMethods::Catalog can manage catalogs from IntrospectionMethods.
Exported functions
set_method_info( target_class, method_name, info_ref )
Store construction info for method method_name of class target_class.
set_global_catalog (target_class, ...)
Store catalog informations. The first parameter is the class featuring the methods declared in the global catalog.
Following paramaters is a set of named paramaters (e.g. key => value):
name
Mandatory name for the global catalog
list
array ref containing the list of slot and catalog. E.g.:
list => [
[qw/foo bar baz/] => foo_catalog,
[qw/a b z/] => alpha_catalog,
my_object => my_catalog
],
isa
Optional hash ref declaring a containment for catalog. E.g:
list => [ foo => USER ,
admin => ROOT ],
isa => { USER => ROOT }
Then the ROOT catalog will return foo, and the USER catalog will return foo and admin.
help
Optional hash ref (slot_name => help). Store some help information for each slot.
set_global_catalog will construct:
A ClassCatalog object containing the global catalog informations.
A sub_ref containing the ClassCatalog object in a closure.
Returns ( slot_name, sub_ref ). The sub_ref is to be installed in the target class.
When called as a class method, the subref will return the ClassCatalog object. When called as a target class method, the subref will return an ObjectCatalog object associated to the ClassCatalog object stored in the closure.
These 2 object have the same API. ObjectCatalog is used to contain catalog changes that may occur at run-time. ClassCatalog informations will not change.
<<lessExported functions
set_method_info( target_class, method_name, info_ref )
Store construction info for method method_name of class target_class.
set_global_catalog (target_class, ...)
Store catalog informations. The first parameter is the class featuring the methods declared in the global catalog.
Following paramaters is a set of named paramaters (e.g. key => value):
name
Mandatory name for the global catalog
list
array ref containing the list of slot and catalog. E.g.:
list => [
[qw/foo bar baz/] => foo_catalog,
[qw/a b z/] => alpha_catalog,
my_object => my_catalog
],
isa
Optional hash ref declaring a containment for catalog. E.g:
list => [ foo => USER ,
admin => ROOT ],
isa => { USER => ROOT }
Then the ROOT catalog will return foo, and the USER catalog will return foo and admin.
help
Optional hash ref (slot_name => help). Store some help information for each slot.
set_global_catalog will construct:
A ClassCatalog object containing the global catalog informations.
A sub_ref containing the ClassCatalog object in a closure.
Returns ( slot_name, sub_ref ). The sub_ref is to be installed in the target class.
When called as a class method, the subref will return the ClassCatalog object. When called as a target class method, the subref will return an ObjectCatalog object associated to the ClassCatalog object stored in the closure.
These 2 object have the same API. ObjectCatalog is used to contain catalog changes that may occur at run-time. ClassCatalog informations will not change.
Download (0.031MB)
Added: 2007-07-18 License: Perl Artistic License Price:
829 downloads
Class::Struct::FIELDS 1.1
Class::Struct::FIELDS module combine Class::Struct, base and fields. more>>
Class::Struct::FIELDS module combine Class::Struct, base and fields.
SYNOPSIS
(This page documents Class::Struct::FIELDS v.1.1.)
use Class::Struct::FIELDS;
# declare struct, based on fields, explicit class name:
struct (CLASS_NAME => { ELEMENT_NAME => ELEMENT_TYPE, ... });
use Class::Struct::FIELDS;
# declare struct, based on fields, explicit class name
# with inheritance:
struct (CLASS_NAME => [qw(BASE_CLASSES ...)],
{ ELEMENT_NAME => ELEMENT_TYPE, ... });
package CLASS_NAME;
use Class::Struct::FIELDS;
# declare struct, based on fields, implicit class name:
struct (ELEMENT_NAME => ELEMENT_TYPE, ...);
package CLASS_NAME;
use Class::Struct::FIELDS;
# declare struct, based on fields, implicit class name
# with inheritance:
struct ([qw(BASE_CLASSES ...)], ELEMENT_NAME => ELEMENT_TYPE, ...);
package MyObj;
use Class::Struct::FIELDS;
# declare struct with four types of elements:
struct (s => $, a => @, h => %, x => &, c => My_Other_Class);
$obj = new MyObj; # constructor
# scalar type accessor:
$element_value = $obj->s; # element value
$obj->s (new value); # assign to element
# array type accessor:
$ary_ref = $obj->a; # reference to whole array
$ary_element_value = $obj->a->[2]; # array element value
$ary_element_value = $obj->a (2); # same thing
$obj->a->[2] = new value; # assign to array element
$obj->a (2, newer value); # same thing
# hash type accessor:
$hash_ref = $obj->h; # reference to whole hash
$hash_element_value = $obj->h->{x}; # hash element value
$hash_element_value = $obj->h (x); # same thing
$obj->h->{x} = new value; # assign to hash element
$obj->h (x, newer value); # same thing
# code type accessor:
$code_ref = $obj->x; # reference to code
$obj->x->(...); # call code
$obj->x (sub {...}); # assign to element
# regexp type accessor:
$regexp = $obj->r; # reference to code
$string =~ m/$obj->r/; # match regexp
$obj->r (qr/ ... /); # assign to element
# class type accessor:
$element_value = $obj->c; # object reference
$obj->c->method (...); # call method of object
$obj->c (My_Other_Class::->new); # assign a new object
Class::Struct::FIELDS exports a single function, struct. Given a list of element names and types, and optionally a class name and/or an array reference of base classes, struct creates a Perl 5 class that implements a "struct-like" data structure with inheritance.
The new class is given a constructor method, new, for creating struct objects.
Each element in the struct data has an accessor method, which is used to assign to the element and to fetch its value. The default accessor can be overridden by declaring a sub of the same name in the package. (See Example 2.)
Each elements type can be scalar, array, hash, code or class.
<<lessSYNOPSIS
(This page documents Class::Struct::FIELDS v.1.1.)
use Class::Struct::FIELDS;
# declare struct, based on fields, explicit class name:
struct (CLASS_NAME => { ELEMENT_NAME => ELEMENT_TYPE, ... });
use Class::Struct::FIELDS;
# declare struct, based on fields, explicit class name
# with inheritance:
struct (CLASS_NAME => [qw(BASE_CLASSES ...)],
{ ELEMENT_NAME => ELEMENT_TYPE, ... });
package CLASS_NAME;
use Class::Struct::FIELDS;
# declare struct, based on fields, implicit class name:
struct (ELEMENT_NAME => ELEMENT_TYPE, ...);
package CLASS_NAME;
use Class::Struct::FIELDS;
# declare struct, based on fields, implicit class name
# with inheritance:
struct ([qw(BASE_CLASSES ...)], ELEMENT_NAME => ELEMENT_TYPE, ...);
package MyObj;
use Class::Struct::FIELDS;
# declare struct with four types of elements:
struct (s => $, a => @, h => %, x => &, c => My_Other_Class);
$obj = new MyObj; # constructor
# scalar type accessor:
$element_value = $obj->s; # element value
$obj->s (new value); # assign to element
# array type accessor:
$ary_ref = $obj->a; # reference to whole array
$ary_element_value = $obj->a->[2]; # array element value
$ary_element_value = $obj->a (2); # same thing
$obj->a->[2] = new value; # assign to array element
$obj->a (2, newer value); # same thing
# hash type accessor:
$hash_ref = $obj->h; # reference to whole hash
$hash_element_value = $obj->h->{x}; # hash element value
$hash_element_value = $obj->h (x); # same thing
$obj->h->{x} = new value; # assign to hash element
$obj->h (x, newer value); # same thing
# code type accessor:
$code_ref = $obj->x; # reference to code
$obj->x->(...); # call code
$obj->x (sub {...}); # assign to element
# regexp type accessor:
$regexp = $obj->r; # reference to code
$string =~ m/$obj->r/; # match regexp
$obj->r (qr/ ... /); # assign to element
# class type accessor:
$element_value = $obj->c; # object reference
$obj->c->method (...); # call method of object
$obj->c (My_Other_Class::->new); # assign a new object
Class::Struct::FIELDS exports a single function, struct. Given a list of element names and types, and optionally a class name and/or an array reference of base classes, struct creates a Perl 5 class that implements a "struct-like" data structure with inheritance.
The new class is given a constructor method, new, for creating struct objects.
Each element in the struct data has an accessor method, which is used to assign to the element and to fetch its value. The default accessor can be overridden by declaring a sub of the same name in the package. (See Example 2.)
Each elements type can be scalar, array, hash, code or class.
Download (0.018MB)
Added: 2007-07-11 License: Perl Artistic License Price:
835 downloads
Class::Classgen::New 3.03
Class::Classgen::New is a Perl module that creates the new() method for classes generated by classgen. more>>
Class::Classgen::New is a Perl module that creates the new() method for classes generated by classgen.
SYNOPSIS
Used within classgen.
The main purpose of New.pm is to write the new() method for a class generated by classgen. It provides code to derive local instance variables with my for all specified instance variables. It provides code to store them within an anonymous hash (only way in the current version). Finally, this hash is blessed into the desired class.
Methods generated by New.pm
In the blessing section of the generated new() method:
inherit_from(): copies the entries of the blessed {} from the base class into the blessed {} of the derived class.
ENVIRONMENT
Nothing special. Just use Perl5.
DIAGNOSTICS
There is no special diagnostics. New.pm is used within classgen which is called with the -w option.
<<lessSYNOPSIS
Used within classgen.
The main purpose of New.pm is to write the new() method for a class generated by classgen. It provides code to derive local instance variables with my for all specified instance variables. It provides code to store them within an anonymous hash (only way in the current version). Finally, this hash is blessed into the desired class.
Methods generated by New.pm
In the blessing section of the generated new() method:
inherit_from(): copies the entries of the blessed {} from the base class into the blessed {} of the derived class.
ENVIRONMENT
Nothing special. Just use Perl5.
DIAGNOSTICS
There is no special diagnostics. New.pm is used within classgen which is called with the -w option.
Download (0.024MB)
Added: 2007-07-10 License: Perl Artistic License Price:
839 downloads
Class::Multimethods::Pure 0.13
Class::Multimethods::Pure is a Perl module that contains a method-ordered multimethod dispatch. more>>
Class::Multimethods::Pure is a Perl module that contains a method-ordered multimethod dispatch.
SYNOPSIS
use Class::Multimethods::Pure;
package A;
sub magic { rand() > 0.5 }
package B;
use base A;
package C;
use base A;
BEGIN {
multi foo => (A, A) => sub {
"Generic catch-all";
};
multi foo => (A, B) => sub {
"More specific";
};
multi foo => (subtype(A, sub { $_[0]->magic }), A) => sub {
"This gets called half the time instead of catch-all";
};
multi foo => (any(B, C), A) => sub {
"Accepts B or C as the first argument, but not A"
};
}
<<lessSYNOPSIS
use Class::Multimethods::Pure;
package A;
sub magic { rand() > 0.5 }
package B;
use base A;
package C;
use base A;
BEGIN {
multi foo => (A, A) => sub {
"Generic catch-all";
};
multi foo => (A, B) => sub {
"More specific";
};
multi foo => (subtype(A, sub { $_[0]->magic }), A) => sub {
"This gets called half the time instead of catch-all";
};
multi foo => (any(B, C), A) => sub {
"Accepts B or C as the first argument, but not A"
};
}
Download (0.015MB)
Added: 2007-07-05 License: Perl Artistic License Price:
843 downloads
Class::Adapter 1.02
Class::Adapter is a Perl implementation of the Adapter Design Pattern. more>>
Class::Adapter is a Perl implementation of the "Adapter" Design Pattern.
The Class::Adapter class is intended as an abstract base class for creating any sort of class or object that follows the Adapter pattern.
What is an Adapter?
The term Adapter refers to a "Design Pattern" of the same name, from the famous "Gang of Four" book "Design Patterns". Although their original implementation was designed for Java and similar single-inheritance strictly-typed langauge, the situation for which it applies is still valid.
An Adapter in this Perl sense of the term is when a class is created to achieve by composition (objects containing other object) something that cant be achieved by inheritance (sub-classing).
This is similar to the Decorator pattern, but is intended to be applied on a class-by-class basis, as opposed to being able to be applied one object at a time, as is the case with the Decorator pattern.
The Class::Adapter object holds a parent object that it "wraps", and when a method is called on the Class::Adapter, it manually calls the same (or different) method with the same (or different) parameters on the parent object contained within it.
Instead of these custom methods being hooked in on an object-by-object basis, they are defined at the class level.
Basically, a Class::Adapter is one of your fall-back positions when Perls inheritance model fails you, or is no longer good enough, and you need to do something twisty in order to make several APIs play nicely with each other.
What can I do with the actual Class::Adapter class
Well... nothing really. It exist to provide some extremely low level fundamental methods, and to provide a common base for inheritance of Adapter classes.
The base Class::Adapter class doesnt even implement a way to push method calls through to the underlying object, since the way in which that happens is the bit that changes from case to case.
To actually DO something, you probably want to go take a look at Class::Adapter::Builder, which makes the creation of Adapter classes relatively quick and easy.
<<lessThe Class::Adapter class is intended as an abstract base class for creating any sort of class or object that follows the Adapter pattern.
What is an Adapter?
The term Adapter refers to a "Design Pattern" of the same name, from the famous "Gang of Four" book "Design Patterns". Although their original implementation was designed for Java and similar single-inheritance strictly-typed langauge, the situation for which it applies is still valid.
An Adapter in this Perl sense of the term is when a class is created to achieve by composition (objects containing other object) something that cant be achieved by inheritance (sub-classing).
This is similar to the Decorator pattern, but is intended to be applied on a class-by-class basis, as opposed to being able to be applied one object at a time, as is the case with the Decorator pattern.
The Class::Adapter object holds a parent object that it "wraps", and when a method is called on the Class::Adapter, it manually calls the same (or different) method with the same (or different) parameters on the parent object contained within it.
Instead of these custom methods being hooked in on an object-by-object basis, they are defined at the class level.
Basically, a Class::Adapter is one of your fall-back positions when Perls inheritance model fails you, or is no longer good enough, and you need to do something twisty in order to make several APIs play nicely with each other.
What can I do with the actual Class::Adapter class
Well... nothing really. It exist to provide some extremely low level fundamental methods, and to provide a common base for inheritance of Adapter classes.
The base Class::Adapter class doesnt even implement a way to push method calls through to the underlying object, since the way in which that happens is the bit that changes from case to case.
To actually DO something, you probably want to go take a look at Class::Adapter::Builder, which makes the creation of Adapter classes relatively quick and easy.
Download (0.024MB)
Added: 2007-06-20 License: Perl Artistic License Price:
856 downloads
Class::NiceApi 0.01.02
Class::NiceApi is a Perl module that translates your methodNames to my method_names. more>>
Class::NiceApi is a Perl module that translates your methodNames to my method_names.
SYNOPSIS
use Class::NiceApi;
my $acl = Class::NiceApi->new( victim => Decision::ACL->new(), style => custom, table => { run_acl => RunACL } );
Perl method names should be written lowercased and multiple words should be connected via _. This is_good_coding_convention. Unfortunately this recommendation is ignored by many CPAN authors. Class::NiceApi helps pernickety programmers as me. It translates method names from isThisPerl to is_this_perl back and forth. Well, it so flexible it can translate allmost anything to anything. So it would translate perl_method_name to java programmers favorite perlMethodName.
METHODS
new()
Takes following parameters (which are also available as methods).
victim
An instance of a class where the method names subjected to translation.
style
A style is just a shortcut for the translation table. Following styles are currently supported: custom, with_underscore and to_lc.
[Note] They are implemented via a translating callback in $Class::NiceApi::callbacks. It filters the source method name and returns the destination name.
table
Here you can list explicit translations of method names, which are exceptions to the custom style filter.
<<lessSYNOPSIS
use Class::NiceApi;
my $acl = Class::NiceApi->new( victim => Decision::ACL->new(), style => custom, table => { run_acl => RunACL } );
Perl method names should be written lowercased and multiple words should be connected via _. This is_good_coding_convention. Unfortunately this recommendation is ignored by many CPAN authors. Class::NiceApi helps pernickety programmers as me. It translates method names from isThisPerl to is_this_perl back and forth. Well, it so flexible it can translate allmost anything to anything. So it would translate perl_method_name to java programmers favorite perlMethodName.
METHODS
new()
Takes following parameters (which are also available as methods).
victim
An instance of a class where the method names subjected to translation.
style
A style is just a shortcut for the translation table. Following styles are currently supported: custom, with_underscore and to_lc.
[Note] They are implemented via a translating callback in $Class::NiceApi::callbacks. It filters the source method name and returns the destination name.
table
Here you can list explicit translations of method names, which are exceptions to the custom style filter.
Download (0.003MB)
Added: 2007-06-20 License: Perl Artistic License Price:
856 downloads
Class::Declare 0.08
Class::Declare is a Perl module created to declare classes with public, private and protected attributes and methods. more>>
Class::Declare is a Perl module created to declare classes with public, private and protected attributes and methods.
SYNOPSIS
package My::Class;
use strict;
use warnings;
use base qw( Class::Declare );
__PACKAGE__->declare(
public => { public_attr => 42 } ,
private => { private_attr => Foo } ,
protected => { protected_attr => Bar } ,
class => { class_attr => [ 3.141 ] }
static => { static_attr => { a => 1 } } ,
restricted => { restricted_attr => string } ,
abstract => abstract_attr ,
friends => main::trustedsub ,
new => [ public_attr , private_attr ] ,
init => sub { # object initialisation
...
1;
} ,
strict => 0
);
sub publicmethod {
my $self = __PACKAGE__->public( shift );
...
}
sub privatemethod {
my $self = __PACKAGE__->private( shift );
...
}
sub protectedmethod {
my $self = __PACKAGE__->protected( shift );
...
}
sub classmethod {
my $self = __PACKAGE__->class( shift );
...
}
sub staticmethod {
my $self = __PACKAGE__->static( shift );
...
}
sub restrictedmethod {
my $self = __PACKAGE__->restricted( shift );
...
}
sub abstractmethod { __PACKAGE__->abstract }
1;
...
my $obj = My::Class->new( public_attr => fish );
MOTIVATION
One of Perls greatest strengths is its flexible object model. You can turn anything (so long as its a reference, or you can get a reference to it) into an object. This allows coders to choose the most appropriate implementation for each specific need, and still maintain a consistent object oriented approach.
A common paradigm for implementing objects in Perl is to use a blessed hash reference, where the keys of the hash represent attributes of the class. This approach is simple, relatively quick, and trivial to extend, but its not very secure. Since we return a reference to the hash directly to the user they can alter hash values without using the classs accessor methods. This allows for coding "short-cuts" which at best reduce the maintainability of the code, and at worst may introduce bugs and inconsistencies not anticipated by the original module author.
On some systems, this may not be too much of a problem. If the developer base is small, then we can trust the users of our modules to Do The Right Thing. However, as a modules user base increases, or the complexity of the systems our modules are embedded in grows, it may become desirable to control what users can and cant access in our module to guarantee our codes behaviour. A traditional method of indicating that an objects data and methods are for internal use only is to prefix attribute and method names with underscores. However, this still relies on the end user Doing The Right Thing.
Class::Declare provides mechanisms for module developers to explicitly state where and how their class attributes and methods may be accessed, as well as hiding the underlying data store of the objects to prevent unwanted tampering with the data of the objects and classes. This provides a robust framework for developing Perl modules consistent with more strongly-typed object oriented languages, such as Java and C++, where classes provide public, private, and protected interfaces to object and class data and methods.
<<lessSYNOPSIS
package My::Class;
use strict;
use warnings;
use base qw( Class::Declare );
__PACKAGE__->declare(
public => { public_attr => 42 } ,
private => { private_attr => Foo } ,
protected => { protected_attr => Bar } ,
class => { class_attr => [ 3.141 ] }
static => { static_attr => { a => 1 } } ,
restricted => { restricted_attr => string } ,
abstract => abstract_attr ,
friends => main::trustedsub ,
new => [ public_attr , private_attr ] ,
init => sub { # object initialisation
...
1;
} ,
strict => 0
);
sub publicmethod {
my $self = __PACKAGE__->public( shift );
...
}
sub privatemethod {
my $self = __PACKAGE__->private( shift );
...
}
sub protectedmethod {
my $self = __PACKAGE__->protected( shift );
...
}
sub classmethod {
my $self = __PACKAGE__->class( shift );
...
}
sub staticmethod {
my $self = __PACKAGE__->static( shift );
...
}
sub restrictedmethod {
my $self = __PACKAGE__->restricted( shift );
...
}
sub abstractmethod { __PACKAGE__->abstract }
1;
...
my $obj = My::Class->new( public_attr => fish );
MOTIVATION
One of Perls greatest strengths is its flexible object model. You can turn anything (so long as its a reference, or you can get a reference to it) into an object. This allows coders to choose the most appropriate implementation for each specific need, and still maintain a consistent object oriented approach.
A common paradigm for implementing objects in Perl is to use a blessed hash reference, where the keys of the hash represent attributes of the class. This approach is simple, relatively quick, and trivial to extend, but its not very secure. Since we return a reference to the hash directly to the user they can alter hash values without using the classs accessor methods. This allows for coding "short-cuts" which at best reduce the maintainability of the code, and at worst may introduce bugs and inconsistencies not anticipated by the original module author.
On some systems, this may not be too much of a problem. If the developer base is small, then we can trust the users of our modules to Do The Right Thing. However, as a modules user base increases, or the complexity of the systems our modules are embedded in grows, it may become desirable to control what users can and cant access in our module to guarantee our codes behaviour. A traditional method of indicating that an objects data and methods are for internal use only is to prefix attribute and method names with underscores. However, this still relies on the end user Doing The Right Thing.
Class::Declare provides mechanisms for module developers to explicitly state where and how their class attributes and methods may be accessed, as well as hiding the underlying data store of the objects to prevent unwanted tampering with the data of the objects and classes. This provides a robust framework for developing Perl modules consistent with more strongly-typed object oriented languages, such as Java and C++, where classes provide public, private, and protected interfaces to object and class data and methods.
Download (0.075MB)
Added: 2007-06-20 License: Perl Artistic License Price:
856 downloads
Class::Declare::Attributes 0.04
Class::Declare::Attributes is a Perl module with Class::Declare method types using Perl attributes. more>>
Class::Declare::Attributes is a Perl module with Class::Declare method types using Perl attributes.
SYNOPSIS
package My::Class;
use 5.006;
use strict;
use warnings;
use base qw( Class::Declare::Attributes );
# declare the class/instance attributes
__PACKAGE__->declare( ... );
#
# declare class/static/restricted/etc methods of this package
#
sub my_abstract : abstract { ... }
sub my_class : class { ... }
sub my_static : static { ... }
sub my_restricted : restricted { ... }
sub my_public : public { ... }
sub my_private : private { ... }
sub my_protected : protected { ... }
Class::Declare::Attributes extends Class::Declare by adding support for Perl attributes for specifying class method types. This extension was inspired by Damian Conways Attribute::Handlers module, and Tatsuhiko Miyagawas Attribute::Protected module. The original implementation used Attribute::Handlers, but now simply refers to attributes.
The addition of Perl attribute support (not to be confused with object attributes, which are entirely different, and also supported by Class::Declare) greatly simplifies the specification of Class::Declare-derived class and instance methods. This should aid in the porting of existing code (Perl, Java and C++) to a Class::Declare framework, as well as simplify the development of new modules.
With the addition of Perl attributes, Class::Declare methods can now be written as
sub method : public
{
my $self = shift;
...
}
instead of
sub method
{
my $self = __PACKAGE__->public( shift );
...
}
<<lessSYNOPSIS
package My::Class;
use 5.006;
use strict;
use warnings;
use base qw( Class::Declare::Attributes );
# declare the class/instance attributes
__PACKAGE__->declare( ... );
#
# declare class/static/restricted/etc methods of this package
#
sub my_abstract : abstract { ... }
sub my_class : class { ... }
sub my_static : static { ... }
sub my_restricted : restricted { ... }
sub my_public : public { ... }
sub my_private : private { ... }
sub my_protected : protected { ... }
Class::Declare::Attributes extends Class::Declare by adding support for Perl attributes for specifying class method types. This extension was inspired by Damian Conways Attribute::Handlers module, and Tatsuhiko Miyagawas Attribute::Protected module. The original implementation used Attribute::Handlers, but now simply refers to attributes.
The addition of Perl attribute support (not to be confused with object attributes, which are entirely different, and also supported by Class::Declare) greatly simplifies the specification of Class::Declare-derived class and instance methods. This should aid in the porting of existing code (Perl, Java and C++) to a Class::Declare framework, as well as simplify the development of new modules.
With the addition of Perl attributes, Class::Declare methods can now be written as
sub method : public
{
my $self = shift;
...
}
instead of
sub method
{
my $self = __PACKAGE__->public( shift );
...
}
Download (0.021MB)
Added: 2007-06-20 License: Perl Artistic License Price:
857 downloads
Secleted [ 0 ] software to compare
Copyright Notice:
Software piracy is theft, Using crack, password, serial numbers, registration codes, key generators is illegal and prevent future software development. The above class search only lists software in full, demo and trial versions for free download. Download links are directly from our mirror sites or publisher sites, torrent files or links from rapidshare.com, yousendit.com or megaupload.com are not allowed