On Sat, Jul 18, 2009 at 03:07:02PM -0700, Christopher Brown wrote: > Moosers: > > Quick question, I hope. > > What I would like is a global way to specify that a meta attribute traits > should be added to all attributes. Take > Moose::Cookbook::Meta::Recipe3<http://search.cpan.org/%7Edrolsky/Moose-0.87/lib/Moose/Cookbook/Meta/Recipe3.pod>, > for instance. Rather than saying > > Traits => 'Labelled' > > for each and every variable, I want to say it once and the traits will be > applied to all of the attributes of a class. Is there a way to due this? > scratch that this is Moose. What is the best way to due this? > > around add_attribute? > adding sugar? > > > This has got to be fairly easy, right? > > Thanks in Advance, > > Chris
What you probably want here is a custom exporter - see the docs for Moose::Util::MetaRole and Moose::Exporter. Extending::Recipe2 shows you how to do it - basically just use apply_metaclass_roles with attribute_metaclass_roles rather than apply_base_class_roles. Jesse
