<div dir="ltr"><div>I wanted to note something (before the week gets started and time vanishes) about how Catalyst is behaving, and see if it&#39;s expected.</div><div><br></div><div>I asked about this on the Moose list, so sorry if you already saw this.</div><div><br></div><div>A Catalyst app extends Catalyst::Component, which has a BUILDARGS sub to merge in class configuration when creating instances of components.</div><div><br></div><div>This is how configuration can set initial values on attributes in Models, Views, Controllers, and the application class itself. </div><div><br></div><div>If a (non-role) Moose-based plugin is loaded (which is common) it&#39;s added to the app&#39;s inheritance like this:</div><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><span style="color:rgb(80,0,80);font-size:12.8px">$meta-&gt;superclasses($plugin, $meta-&gt;superclasses);</span></div></blockquote><div><br></div><div> Which can be thought of like this:</div><div><br></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>@App::ISA = ( qw/ Catalyst::Plugin::Foo  Catalyst / );</div></blockquote></div><div><br></div><div>The result then is that BUILDARGS in Catalyst::Component is no longer called, and then attributes in the App class are no longer populated from the config.</div><div><br></div><div>So, the behavior changes depending on what plugins are brought in.</div><div><br></div><div><br></div>Another odd issue I came against is that <span style="font-size:12.8px">MooseX::Emulate::Class::</span><span style="font-size:12.8px">Accessor::Fast causes odd behavior of Moose attributes.   This role is widely used in Catalyst.</span><div><span style="font-size:12.8px"><br></span></div><div><div><span style="font-size:12.8px">In the code below note how the &quot;foo&quot; attribute has init_arg =&gt; undef to prevent it from being initialized.  With the the role not only is it initialized, but with a value that isn&#39;t an &quot;Int&quot;.</span><br></div><div><span style="font-size:12.8px"><br></span></div><div><br></div><div><blockquote style="font-size:12.8px;margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_extra"><div class="gmail_quote">package Foo;</div></div><div class="gmail_extra"><div class="gmail_quote">use Moose;</div></div><div class="gmail_extra"><div class="gmail_quote"><br></div></div><div class="gmail_extra"><div class="gmail_quote">with &#39;MooseX::Emulate::Class::Accessor::Fast&#39;;</div></div><span class="im"><div class="gmail_extra"><div class="gmail_quote"><br></div></div><div class="gmail_extra"><div class="gmail_quote">has foo =&gt; (</div></div><div class="gmail_extra"><div class="gmail_quote">    is  =&gt; &#39;ro&#39;,</div></div></span><div class="gmail_extra"><div class="gmail_quote">    isa =&gt; &#39;Int&#39;, # for error</div></div><div class="gmail_extra"><div class="gmail_quote">    init_arg =&gt; undef,</div></div><div class="gmail_extra"><div class="gmail_quote">);</div></div><span class="im"><div class="gmail_extra"><div class="gmail_quote"><br></div></div><div class="gmail_extra"><div class="gmail_quote"><br></div></div><div class="gmail_extra"><div class="gmail_quote">package main;</div></div><div class="gmail_extra"><div class="gmail_quote">use strict;</div></div><div class="gmail_extra"><div class="gmail_quote">use warnings;</div></div><div class="gmail_extra"><div class="gmail_quote"><br></div></div></span><div class="gmail_extra"><div class="gmail_quote">my $foo = Foo-&gt;new( { foo =&gt; &#39;bar&#39; } );</div></div><div class="gmail_extra"><div class="gmail_quote"><br></div></div><div class="gmail_extra"><div class="gmail_quote">use Data::Dumper;</div></div><div class="gmail_extra"><div class="gmail_quote">print Dumper $foo-&gt;foo;</div></div></blockquote><div class="gmail_extra" style="font-size:12.8px"><div class="gmail_quote"><div><br></div><div>Generates &#39;bar&#39;, which is not an Int.</div><div><br></div></div></div><blockquote style="font-size:12.8px;margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_extra"><div class="gmail_quote">$VAR1 = &#39;bar&#39;;</div></div></blockquote><div class="gmail_extra" style="font-size:12.8px"><div class="gmail_quote"></div></div><div><div><br></div><div><div><span style="font-size:12.8px">Comment out &quot;</span><span style="font-size:12.8px">with &#39;MooseX::Emulate::Class::</span><span style="font-size:12.8px">Accessor::Fast&#39;;&quot; and it behaves as expected.   Also comment out &quot;init_arg&quot; and Moose will complain about the string not begin an Int.</span></div><div><div class="gmail_extra" style="font-size:12.8px"><div class="gmail_quote"></div></div></div></div><div><br></div><div><br></div>-- <br><div class="gmail_signature">Bill Moseley<br><a href="mailto:moseley@hank.org" target="_blank">moseley@hank.org</a></div>
</div></div></div></div>