Class: CloudfujiLeadObserver

Inherits:
ActiveRecord::Observer
  • Object
show all
Defined in:
app/observers/cloudfuji_lead_observer.rb

Overview

Fat Free CRM Copyright © 2008-2011 by Michael Dvorkin

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <www.gnu.org/licenses/>.


Instance Method Summary collapse

Instance Method Details

#after_update(lead) ⇒ Object



21
22
23
24
25
26
27
# File 'app/observers/cloudfuji_lead_observer.rb', line 21

def after_update(lead)
  # Find all event rules where the lead attribute is one of the changed fields
  EventRule.find_all_by_event_category_and_lead_attribute('lead_attribute_changed', lead.changes.keys).each do |rule|
    old, new = lead.changes[rule.lead_attribute]
    rule.process(lead, {'old_value' => old, 'new_value' => new})  # Send [old, new] values as matching data
  end
end