Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: MooseX::Declare and overload

by FunkyMonk (Chancellor)
on Apr 01, 2010 at 10:17 UTC ( [id://832271]=note: print w/replies, xml ) Need Help??


in reply to Re: MooseX::Declare and overload
in thread MooseX::Declare and overload

Awesomer! Thanks Haarg++

This worked, but only when I declared to_string as a sub instead of a method, but I can live with that. And extra thanks for pointing out the bug in namespace::autoclean. That explained the problem clearly.

Replies are listed 'Best First'.
Re^3: MooseX::Declare and overload
by Haarg (Priest) on Apr 01, 2010 at 16:41 UTC
    There is still a lot of black magic in MooseX::Declare interfering, but if you use use overload '""' => 'to_string'; instead of referencing it symbolically, it should work if to_string is defined as either a sub or a method. It will also allow subclasses to override the stringification behavior.
      You hit the nail on the head.
      class InDeclareString is dirty { use overload '""' => 'to_string'; has val => (is => 'rw'); method to_string { sprintf "(%s)", $self->val } };

      works perfectly.

      Many thanks

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://832271]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-19 12:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found