Sha256: 9af2a2438bb7dcf90614fb2d362161c6789092bbf2edea5e7ac2c3518c6eaf01

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

# Fat Free CRM
# Copyright (C) 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 <http://www.gnu.org/licenses/>.
#------------------------------------------------------------------------------

class CloudfujiLeadObserver < ActiveRecord::Observer
  observe :lead

  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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ffcrm_cloudfuji-0.4.1 app/observers/cloudfuji_lead_observer.rb