Sha256: 08903eba081987061492556e6e54cd5fd1591b57b3bfbff5342d5b76565d8a7f

Contents?: true

Size: 1.17 KB

Versions: 9

Compression:

Stored size: 1.17 KB

Contents

module FatFreeCRM
  module Cloudfuji
    module EventObservers
      class ErrorObserver < ::Cloudfuji::EventObserver
        include FatFreeCRM::Cloudfuji::EventObservers::Base
        include ActionView::Helpers::TextHelper

        def error_caught
          email = data['email'] || data['recipient']
          # Look up Lead by ido_id, fall back to email address
          if user_attributes = data['user_attributes']
            lead = Lead.find_by_ido_id(user_attributes['ido_id']) if user_attributes['ido_id'].present?
            lead ||= Lead.find_by_email(user_attributes['email'])
            if lead
              # Set ido_id if blank
              user_attributes

              occurence = ActiveSupport::Inflector.ordinalize(data['occurrences'])
              message = "Error experienced in <strong>#{data['app_name']}</strong> [#{data['environment_name']}] (#{occurence} time): "
              message << "<em>" << truncate(data['message'], :length => 75) << "</em>"
              message << "<br />View the error at: #{data['url']}" if data['url']
              lead.versions.create! :event => message
            end
          end
        end

      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ffcrm_cloudfuji-0.4.1 lib/fat_free_crm/cloudfuji/event_observers/error_observer.rb
ffcrm_cloudfuji-0.3.1 lib/fat_free_crm/cloudfuji/event_observers/error_observer.rb
ffcrm_cloudfuji-0.3.0 lib/fat_free_crm/cloudfuji/event_observers/error_observer.rb
ffcrm_cloudfuji-0.2.11 lib/fat_free_crm/cloudfuji/event_observers/error_observer.rb
ffcrm_cloudfuji-0.2.10 lib/fat_free_crm/cloudfuji/event_observers/error_observer.rb
ffcrm_cloudfuji-0.2.9 lib/fat_free_crm/cloudfuji/event_observers/error_observer.rb
ffcrm_cloudfuji-0.2.8 lib/fat_free_crm/cloudfuji/event_observers/error_observer.rb
ffcrm_cloudfuji-0.2.7 lib/fat_free_crm/cloudfuji/event_observers/error_observer.rb
ffcrm_cloudfuji-0.2.6 lib/fat_free_crm/cloudfuji/event_observers/error_observer.rb