Sha256: a282a317c74e83a0add95af867b6cacb478c89e41ecfd3a7d6718de8c65fc673
Contents?: true
Size: 1.26 KB
Versions: 9
Compression:
Stored size: 1.26 KB
Contents
module ErpBaseErpSvcs module Extensions module ActiveRecord module HasContact def self.included(base) base.extend(ClassMethods) end module ClassMethods def has_contact extend HasContact::SingletonMethods include HasContact::InstanceMethods after_initialize :initialize_contact after_create :save_contact after_update :save_contact after_destroy :destroy_contact has_one :contact, :as => :contact_mechanism end end module SingletonMethods end module InstanceMethods # return first contact purpose def contact_purpose contact.contact_purposes.count == 0 ? nil : contact.contact_purposes.first end # return all contact purposes def contact_purposes contact.contact_purposes end def save_contact self.contact.save end def destroy_contact self.contact.destroy unless self.contact.nil? end def initialize_contact if self.new_record? and self.contact.nil? self.contact = Contact.new self.contact.description = self.description end end end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems