I need some help debugging this. In Catalyst::Model::DBIC::Schema::Types there's this:
subtype LoadedClass, as ClassName; coerce LoadedClass, from Str, # N.B. deliberate paranoia against $_ clobbering below *via { my $classname = $_; Class::MOP::load_class($classname); $classname };* And this attribute is created: has pool_type => (is => 'ro', isa => LoadedClass); I'm getting this error: Couldn't instantiate component "MyApp::Model::DB", "Attribute (pool_type) does not pass the type constraint because: Validation failed for 'Catalyst::Model::DBIC::Schema::Types::LoadedClass' with *value "MyApp::DB::Pool"* at /Users/bill/perl5/perlbrew/perls/perl-5.16.1/lib/site_perl/5.16.1/darwin-2level/Moose/Meta/Attribute.pm line 1289, <DATA> line 1000. The value is indeed a string. If I "use MyApp::DB::Pool" someplace then the error goes away. If I modify "via" above to: via { my $classname = $_; warn "*** LOADING $classname ***\n"; Class::MOP::load_class($classname); $classname }; I see other class names loaded but not for "MyApp::DB::Pool". So, for some reason that via block isn't getting called for this attribute. Can someone provide some tips on how to debug why that "via" block is not being called? Does it not think it's a Str? ($value is a string.) Or could the via block be replaced or not set for that attribute? I'm sooting in the dark here, but if I Data::Dumper the pool_type attribute I can see the LoadedClass constraint. $VAR1 = bless( { 'reader' => 'pool_type', 'init_arg' => 'pool_type', 'name' => 'pool_type', 'type_constraint' => bless( { '__type_constraint' => bless( { 'compiled_type_constraint' => sub {"DUMMY"}, 'parent' => bless( { 'compiled_type_constraint' => 'CODE(0x7ffb032f80b8)', 'parent' => 'Str', 'name' => 'ClassName', 'inline_environment' => 'HASH(0x7ffb032f7e78)', 'inlined' => 'CODE(0x7ffb032ee7b0)', 'constraint' => 'CODE(0x7ffb032ee6f0)', '_default_message' => 'CODE(0x7ffb032f7bd8)', 'package_defined_in' => 'Moose::Util::TypeConstraints::Builtins' }, 'Moose::Meta::TypeConstraint' ), 'coercion' => bless( { 'compiled_type_coercion' => 'CODE(0x7ffb088a5e08)', 'type_coercion_map' => 'ARRAY(0x7ffb07bdfb00)', ( this is Str and a coderef ). 'type_constraint' => undef }, 'Moose::Meta::TypeCoercion' ), * 'name' => 'Catalyst::Model::DBIC::Schema::Types::LoadedClass',* 'inline_environment' => {}, '_default_message' => sub {"DUMMY"}, 'package_defined_in' => 'Moose::Exporter', 'constraint' => sub {"DUMMY"} }, 'Moose::Meta::TypeConstraint' ) }, 'MooseX::Types::TypeDecorator' ), 'is' => 'ro', 'associated_methods' => [], 'isa' => $VAR1->{'type_constraint'}, 'definition_context' => { 'context' => 'has declaration', 'file' => '/Users/bill/perl5/perlbrew/perls/perl-5.16.1/lib/site_perl/5.16.1/Catalyst/TraitFor/Model/DBIC/Schema/Replicated.pm', 'type' => 'role', 'package' => 'Catalyst::TraitFor::Model::DBIC::Schema::Replicated', 'line' => 77 } }, 'Moose::Meta::Attribute' ); -- Bill Moseley mose...@hank.org