Module: ErpBaseErpSvcs::Extensions::ActiveRecord::IsContactMechanism::InstanceMethods
- Defined in:
- lib/erp_base_erp_svcs/extensions/active_record/is_contact_mechanism.rb
Instance Method Summary collapse
- #add_contact_purpose(contact_purpose) ⇒ Object
-
#contact_purpose_iids ⇒ Object
return all contact purpose iids in one comma separated string.
-
#contact_purposes ⇒ Object
return all contact purposes.
-
#contact_purposes_to_s ⇒ Object
return all contact purposes in one comma separated string.
- #destroy_contact ⇒ Object
- #initialize_contact ⇒ Object
- #save_contact ⇒ Object
Instance Method Details
#add_contact_purpose(contact_purpose) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/erp_base_erp_svcs/extensions/active_record/is_contact_mechanism.rb', line 56 def add_contact_purpose(contact_purpose) unless contact_purpose.is_a?(ContactPurpose) contact_purpose = ContactPurpose.iid(contact_purpose) end # don't add the contact purpose if its already there unless contact_purpose_iids.include?(contact_purpose.internal_identifier) contact.contact_purposes << contact_purpose contact.save end end |
#contact_purpose_iids ⇒ Object
return all contact purpose iids in one comma separated string
69 70 71 |
# File 'lib/erp_base_erp_svcs/extensions/active_record/is_contact_mechanism.rb', line 69 def contact_purpose_iids contact.contact_purposes.collect(&:internal_identifier).join(',') end |
#contact_purposes ⇒ Object
return all contact purposes
74 75 76 |
# File 'lib/erp_base_erp_svcs/extensions/active_record/is_contact_mechanism.rb', line 74 def contact_purposes contact.contact_purposes end |
#contact_purposes_to_s ⇒ Object
return all contact purposes in one comma separated string
52 53 54 |
# File 'lib/erp_base_erp_svcs/extensions/active_record/is_contact_mechanism.rb', line 52 def contact_purposes_to_s contact.contact_purposes.collect(&:description).join(', ') end |
#destroy_contact ⇒ Object
78 79 80 |
# File 'lib/erp_base_erp_svcs/extensions/active_record/is_contact_mechanism.rb', line 78 def destroy_contact self.contact.destroy unless self.contact.nil? end |
#initialize_contact ⇒ Object
82 83 84 85 86 87 |
# File 'lib/erp_base_erp_svcs/extensions/active_record/is_contact_mechanism.rb', line 82 def initialize_contact if self.new_record? and self.contact.nil? self.contact = Contact.new self.contact.description = self.description end end |
#save_contact ⇒ Object
47 48 49 |
# File 'lib/erp_base_erp_svcs/extensions/active_record/is_contact_mechanism.rb', line 47 def save_contact self.contact.save end |