Module: Insight::CRM::Callbacks::User
- Defined in:
- lib/insight/crm/callbacks/user.rb
Class Method Summary collapse
Instance Method Summary collapse
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 |
# File 'lib/insight/crm/callbacks/user.rb', line 9 def self.included(base) base.class_eval do after_create :create_crm_contact 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 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 end |
Instance Method Details
#create_crm_contact ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/insight/crm/callbacks/user.rb', line 16 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
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/insight/crm/callbacks/user.rb', line 24 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 |