Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: Class Attributes with Moo ?

by tobyink (Abbot)
on Dec 27, 2012 at 07:53 UTC ( #1010465=note: print w/replies, xml ) Need Help??

in reply to Class Attributes with Moo ?

Yes, this is a MooX module I've been meaning to write for some time. Like you, I've been using package variables, but a proper class attribute would give you delegation, type constraints, triggers, etc.

I may have a stab at writing something along these lines in the next couple of weeks. I just need to delve into the Method::Generate::* code to see how feasible it might be.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Replies are listed 'Best First'.
Re^2: Class Attributes with Moo ?
by mascip (Pilgrim) on Dec 27, 2012 at 16:22 UTC

    Thank you for your reply :-) I was wondering if i was missing anything.
    In the future if i need to use inheritance, i might put this timer as a simple attribute, and pass it to my objects from the client code. It's giving some non-related job to the client, but it should do the trick.
    I'll keep an eye open, in case you created a new MooX module. Sorry i cannot help : i don't have the skills nor the time to develop them right now.

      OK, MooX::ClassAttribute is now on CPAN. Subclassing Method::Generate::Accessor to generate class attributes was relatively easy. The hard parts were getting class attributes defined in roles to work, and getting Moose inflation going.

      perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

        Wow, that was fast! You're a star thanks a lot :-)

Re^2: Class Attributes with Moo ?
by mascip (Pilgrim) on Dec 28, 2012 at 07:29 UTC

    I don't have the time to try it today, but maybe tomorrow : Class::Data::Inheritable might do the trick according to its documentation.
    This could be enough for me right now.

    The annoying bit is that you have to inherit from Class::Data::Inheritable. I'm not sure how annoying that could be though.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1010465]
Corion had a meeting with some startup today. They have a very interesting DB proxy product, but their tech stack is really, really weird. They use the Pg wire protocol but not the Pg libraries to handle it. They support Pg SQL syntax, but don't use ...
[Corion]: ... the Pg parser (or so they claim).
[Corion]: Also, they rolled their own user management instead of supporting LDAP for user/role management, but that just shows that they're new in the enterprise market :)
Corion also just now realizes they didn't leave business cards.

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (9)
As of 2018-04-19 12:17 GMT
Find Nodes?
    Voting Booth?