<div class="gmail_quote">On Thu, Aug 26, 2010 at 3:33 AM, Peter Rabbitson <span dir="ltr">&lt;<a href="mailto:rabbit%2Bdbic@rabbit.us">rabbit+dbic@rabbit.us</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="im">Pavel A. Karoukin wrote:<br>
&gt; Hello,<br>
&gt;<br>
&gt; I am trying to make something work nice, but it doesn&#39;t want to =)<br>
&gt; Probably, it&#39;s just by design, or I am missing something.<br>
&gt;<br>
</div><div class="im">&gt; Question: is it possible to make it work with $user-&gt;data-&gt;{test} = 1;<br>
&gt; notation? I.e. I do not want to create new methods in results class, not<br>
&gt; want to extract hash from field first and then save it?<br>
<br>
</div>Absolutely impossible, since the whole idea of InflateColumn is:<br>
*) A plain scalar value supplied to new/update is assumed to be an<br>
already-deflated value to be placed directly in the database<br>
*) Any type of reference (blessed or not) is a candidate for deflation<br>
and passed on to the deflator<br>
<br>
However you may find that FilterColumn does exactly what you want to<br>
do.<br><br></blockquote><div><br></div><div>Peter,</div><div><br></div><div>Thank you for pointing to FilterColumn. I&#39;ve tried it with almost same result tho.. Probably I am doing something wrong?</div><div><br></div>

<div>I.e. I replaced __PACKAGE__inflate_column with:</div><div><br></div><div>__PACKAGE__-&gt;filter_column(</div><div>    &#39;data&#39; =&gt; {</div><div>      filter_to_storage =&gt; &#39;__data_to_storage&#39;,</div>
<div>
      filter_from_storage =&gt; &#39;__data_from_storage&#39;,</div><div>    },</div><div>);</div><div><br></div><div><br></div><div>sub __data_to_storage {</div><div>  my ($self, $data) = @_;</div><div>  return encode_json($data);</div>

<div>}</div><div><br></div><div>sub __data_from_storage {</div><div>  my ($self, $data) = @_;</div><div>  return decode_json($data);</div><div>}</div><div><br></div><div><br></div><div>And now in my controller code trying this:</div>

<div><br></div><div><div>  $c-&gt;user-&gt;data-&gt;{test}; # return &quot;yes&quot; as stored in DB in JSON format</div><div>  $c-&gt;user-&gt;data-&gt;{test} = &quot;no&quot;; # now this contain &quot;no&quot;, but not stored in DB yet</div>

<div>  $c-&gt;user-&gt;update(); # I thought it should pass $c-&gt;user-&gt;date to __data_to_storage(), but it never do this. Why?</div></div><div><br></div><div>So so far it behaive the same way as InflateColumn =(</div>

<div><br></div><div>Regads,</div><div>Pavel</div><div><br></div></div>