Module: Insight::CRM::Callbacks::User
- Defined in:
- lib/insight/crm/callbacks/user.rb
Class Method Summary collapse
Instance Method Summary collapse
- #create_crm_contact ⇒ Object
-
#crm_attributes ⇒ Object
def update_crm_contact contact = CRM::Models::Contact.find(crm_id) contact.attributes = crm_attributes contact.save end.
Class Method Details
.included(base) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/insight/crm/callbacks/user.rb', line 9 def self.included(base) base.class_eval do after_create :create_crm_contact # after_update :update_crm_contact, :unless => :recording_last_activity? end protected def create_crm_contact contact = CRM::Models::Contact.new contact.attributes = crm_attributes contact.user_id = 1 contact.save self.update_attribute(:crm_id, contact.id) end # def update_crm_contact # contact = CRM::Models::Contact.find(crm_id) # contact.attributes = crm_attributes # contact.save # end def crm_attributes a = {} a[:title] = title if respond_to?(:title) a[:first_name] = firstname if respond_to?(:firstname) a[:first_name] = first_name if respond_to?(:first_name) a[:last_name] = lastname if respond_to?(:lastname) a[:last_name] = last_name if respond_to?(:last_name) a[:email] = email if respond_to?(:email) a[:username] = username if respond_to?(:username) a end # def recording_last_activity? # respond_to?(:last_activity) && last_activity_changed? # end end |
Instance Method Details
#create_crm_contact ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/insight/crm/callbacks/user.rb', line 17 def create_crm_contact contact = CRM::Models::Contact.new contact.attributes = crm_attributes contact.user_id = 1 contact.save self.update_attribute(:crm_id, contact.id) end |
#crm_attributes ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/insight/crm/callbacks/user.rb', line 31 def crm_attributes a = {} a[:title] = title if respond_to?(:title) a[:first_name] = firstname if respond_to?(:firstname) a[:first_name] = first_name if respond_to?(:first_name) a[:last_name] = lastname if respond_to?(:lastname) a[:last_name] = last_name if respond_to?(:last_name) a[:email] = email if respond_to?(:email) a[:username] = username if respond_to?(:username) a end |