title: ActiveModel: Mimic a column type datetime
body: <p>I am using an ActiveModel model <code>DateRange</code> with attributes <code>:from</code> and <code>:to</code> and I want it to behave as follows..<br>
  <br></p>
  
  <pre><code>  d = DateRange.new
  =&gt; #&lt;DateRange:0x0000010532d3f8&gt;
    d.from = "03/03/2010"
  =&gt; Wed, 03 Mar 2010
    d.to  = Date.today
  =&gt; Mon, 3 Mar 2014
  </code></pre>
  
  <p>In other words, whenever an attribute is set, if it is in string format it should be parsed into a date format.<br>
  Is there an ActiveModel callback function which will run immediately when an attribute is changed? If not, what would be best practice to do this?</p>