in reply to Re: What About Providing Constructors in Roles?
in thread What About Providing Constructors in Roles?

"The constructor you provided does nothing..."

Yes and no. At least it returns the blessed ref.

"...if the constructor had parameters..."

But it has parameters, doesn't it?

"...use the same parameters for all the classes consuming the role..."

No. And yes. Just passing in the hash ref.

"...classes based on Moo/Moose..."

This is what i wanted to avoid.

"...trying to achieve?"

Nothing. This is just an exercise.

Basic idea:

  1. Provide a "generic" constructor (first role)
  2. Specify attributes (next role)
  3. Specify accessors/behaviour (class)
  4. Modify attributes/accessors/behaviour (plugin)

Best regards, Karl

«The Crux of the Biscuit is the Apostrophe»

perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help