title: Rails, ActiveRecord: Callback run during #reload
body: <p>I have a model with an attribute that is generated from the values of the persisted column values.</p>
  
  <pre><code>class Result &lt; ActiveRecord::Base
    belongs_to :job
    belongs_to :customer
    has_many :records, through: :job
  
    def processed_records
      @processed_records ||=
        begin
          status_flagged + status_invalid +
            status_unknown + status_valid
        end
    end
  end
  </code></pre>
  
  <p>My problem is that the Result object sometimes has to call #reload to get new values from the DB. Is there a callback I can hook into to clear the value of <code>@processed_records</code>, so that the next call will re-compute the value?</p>
  
  <p>In other words, I'd like this to work:</p>
  
  <pre><code>RSpec.describe Result, :type =&gt; :model do
    subject { create(:result) }
  
    it 'should update #processed_records on reload' do
      initial_value = subject.processed_records
  
      other_instance = Result.find(subject.id)
      other_instance.increment(:status_flagged)
      other_instance.save
  
      subject.reload
      expect(subject.processed_records).to eq(initial_value + 1)
    end
  end
  </code></pre>