in reply to Extending objects

> And, please, I don't want to know how to do it with Moose.

Have been using Object::InsideOut recently. I find it can fit inside one's mind all at the same time. Unlike moose, where the bits keep falling out ... :-)

O::IO supports multiple inheritance, so one could write the following. (If all you required was already implemented in Foo and Bar, this really would be all the code.)

package MyProject::FooBar; { use Object::InsideOut qw(MyProject::Foo MyProject::Bar); } 1;

Example of use

my $foobar = MyProject::FooBar->new( name=>'Bob', age=>32 );

Replies are listed 'Best First'.
Re^2: Extending objects
by nudge (Acolyte) on Jul 08, 2010 at 02:38 UTC

    Replying to my own post to provide a full example.

    ### Name.pm ###

    package Name; { use Object::InsideOut; my @name :Field :All(name); } 1;

    ### Age.pm ###

    package Age; { use Object::InsideOut; my @age :Field :All(age) :Type(numeric); } 1;

    ### Person.pm ###

    use Name; use Age; package Person; { use Object::InsideOut qw(Name Age); } 1;

    ### main ###

    #!/usr/bin/perl use Person; my $person = Person->new( name => 'Bob', age => 32 ); print "Person's name is ", $person->name(); print " and age is ", $person->age(), "\n";