<div dir="ltr">Hah! You&#39;re right! It does work.<div><br></div><div>It was just me failing to realize that the errors were actually thrown at load time, not inflate time. The problem is putting a &quot;dumb&quot; under MyApp::Schema::Result:: because DBIx::Class will try to load and initialize it as a normal result class during DBIx::Class::Schema-&gt;load_namespaces().<div><br></div><div>Putting the dumb result class outside the MyApp::Schema::Result:: namespace works just fine.</div><div><br></div><div>Thanks for your help both of you.</div><div><br></div><div>/L</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 9, 2015 at 5:34 PM, Dmitry L. <span dir="ltr">&lt;<a href="mailto:dim0xff@gmail.com" target="_blank">dim0xff@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Strange. Your example just works for me.<br>
I tried it with DBIC example ( DBIx::Class::Manual::Example ) without<br>
any changes, just copy-paste.<br>
<br>
And yes, I use the latest DBIC.<br>
<div class="HOEnZb"><div class="h5"><br>
On 9 April 2015 at 16:58, Lasse Makholm &lt;<a href="mailto:lasse@unity3d.com">lasse@unity3d.com</a>&gt; wrote:<br>
&gt; I&#39;m using DBIx::Class::ResultClass::HashRefInflator in some places where<br>
&gt; full row object inflation is too slow. That&#39;s fine.<br>
&gt;<br>
&gt; What I&#39;d really like to do though, is bless the resulting hashrefs into a<br>
&gt; &quot;light weight&quot; result class that provides a few convenience methods but<br>
&gt; knows little to nothing about DBIx::Class.<br>
&gt;<br>
&gt; Trying something like:<br>
&gt;<br>
&gt; my $rs = $schema-&gt;resultset(&#39;MyTable&#39;)-&gt;search(...);<br>
&gt; $rs-&gt;result_class(&#39;MyApp::Schema::DumbResult::MyTable&#39;);<br>
&gt; while (my $thingy = $rs-&gt;next) {<br>
&gt;<br>
&gt; # do, do, do<br>
&gt;<br>
&gt; }<br>
&gt;<br>
&gt;<br>
&gt; with something like:<br>
&gt;<br>
&gt; package MyApp::Schema::DumbResult::MyTable;<br>
&gt;<br>
&gt; use strict;<br>
&gt; use warnings;<br>
&gt;<br>
&gt; use DBIx::Class::ResultClass::HashRefInflator;<br>
&gt;<br>
&gt; sub inflate_result<br>
&gt; {<br>
&gt; my $class = shift;<br>
&gt; my $result = DBIx::Class::ResultClass::HashRefInflator-&gt;inflate_result(@_);<br>
&gt; return bless $result, $class;<br>
&gt; }<br>
&gt;<br>
&gt; sub TO_JSON<br>
&gt; {<br>
&gt; my $self = shift;<br>
&gt; return { %$self };<br>
&gt; }<br>
&gt;<br>
&gt; 1;<br>
&gt;<br>
&gt;<br>
&gt; ...breaks for a variety of reasons it seems, because DBIx::Class wants to do<br>
&gt; things like setting a result source instance on the result object, etc...<br>
&gt;<br>
&gt; Is there an (easy) make this work? Or is it just in general a horrible idea?<br>
&gt;<br>
&gt; Of course I can just do:<br>
&gt;<br>
&gt; $rs-&gt;result_class(&#39;DBIx::Class::ResultClass::HashRefInflator&#39;);<br>
&gt; my @stuff = map { bless $_, MyApp::Schema::DumbResult::MyTable } $rs-&gt;all;<br>
&gt;<br>
&gt; ...but the other way is more convenient...<br>
&gt;<br>
&gt; Or is it more sane to subclass the ResultSet and override first(), all() and<br>
&gt; next() to set the result_class and bless the resulting hashrefs?<br>
&gt;<br>
&gt; Any input appreciated?<br>
&gt;<br>
&gt; /L<br>
&gt;<br>
&gt;<br>
&gt;<br>
</div></div><span class="im HOEnZb">&gt; _______________________________________________<br>
&gt; List: <a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class" target="_blank">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class</a><br>
&gt; IRC: <a href="http://irc.perl.org#dbix-class" target="_blank">irc.perl.org#dbix-class</a><br>
&gt; SVN: <a href="http://dev.catalyst.perl.org/repos/bast/DBIx-Class/" target="_blank">http://dev.catalyst.perl.org/repos/bast/DBIx-Class/</a><br>
&gt; Searchable Archive:<br>
&gt; <a href="http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk" target="_blank">http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk</a><br>
<br>
<br>
<br>
</span><span class="HOEnZb"><font color="#888888">--<br>
//wbr, Dmitry L.<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
_______________________________________________<br>
List: <a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class" target="_blank">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class</a><br>
IRC: <a href="http://irc.perl.org#dbix-class" target="_blank">irc.perl.org#dbix-class</a><br>
SVN: <a href="http://dev.catalyst.perl.org/repos/bast/DBIx-Class/" target="_blank">http://dev.catalyst.perl.org/repos/bast/DBIx-Class/</a><br>
Searchable Archive: <a href="http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk" target="_blank">http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk</a><br>
</div></div></blockquote></div><br></div>