Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Role composition doesn't solve the method-explosion problem. Suggesting it does actually hides the obvious solution to the problem because to properly implement your role you need to create an ORM delegate anyway. The proper solution to this in Moose terms is:

        package Server;
        use Moose -traits Persistent( storage => SomeORM );

        has ip_address => ( i
            sa => 'IPAddress',
            is => 'ro',
            traits => ['Persisted']

        has name => (
            isa => 'Str',
            is => 'ro',
            traits => ['Persisted']

        sub restart {
            my ( $self, $nice ) = @_;
            say $nice ? 'yes' : 'no';

    Where Persistent is a parameterized role applied to the metaclass, and SomeORM is a parameter to define what storage engine to use. Effectively your Class's instance has-a ORM and that ORM is used to persist the attributes you care about.

    To be more blunt, dami is correct ... the relationship between between SomeORM and Server is 'has' not 'does' or 'is'. Your use of roles there doesn't change that fact it simply hides the implementation you're complaining about somewhere useful for the sake of your argument.