FAQ
One of the features of a module I'm trying to get released (I've been
working on it for 2+ months now, Catalyst::Model::DBIC::Schema) is trait
support from config, with search.

It seems other people are interested in this too, so I'd like some help
hashing out the syntax so that we don't end up with different syntaxes
for different modules.

After some discussion with t0m and some more thought I realized that my
approach of just searching @ISA is wrong. Below is the approach I'm
thinking of now (which could be wrong too, but just something to start
with...)

For this example we'll use Catalyst::Model::DBIC::Schema as the base
class, and MyApp::Model::DB as the subclass.

The inheritance hierarchy is something like this:

Moose::Object -> C::Component -> C::Model ->
C::M::DBIC::Schema -> MyApp::Model::DB

1) + prefix

traits => ['+Foo']

Will apply the role whose full package name is 'Foo'

2) no prefix

traits => ['Foo']

Will apply 'MyApp::Model::DBIC::Schema::Trait::Foo'

3) ~ prefix

traits => ['~Foo']

Will search for, in this order:
MyApp::Model::DB::Trait::Foo
MyApp::Model::DBIC::Schema::Trait::Foo
Catalyst::Model::DBIC::Schema::Trait::Foo
MyApp::Model::Trait::Foo
Catalyst::Model::Trait::Foo
MyApp::Component::Trait::Foo
Catalyst::Component::Trait::Foo
Moose::Object::Trait::Foo

Or something like that, not sure how that would get implemented yet.

Maybe that's too complicated.

Once this is decided, I will probably add it to
MooseX::Traits::Pluggable as '+_trait_ns' => '~Trait', and make a
CatalystX::Component::Traits role on top of that that would give you the
COMPONENT implementation that
does the trait loading from config and calls new_with_traits.

--
Caelum

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcatalyst-dev @
categoriescatalyst, perl
postedJun 7, '09 at 1:02a
activeJun 7, '09 at 1:02a
posts1
users1
websitecatalystframework.org
irc#catalyst

1 user in discussion

Rafael Kitover: 1 post

People

Translate

site design / logo © 2021 Grokbase