Sha256: 1dd83a2d4e16a271fe6a91da76be2a6414a41cbf48316e0864c7d423f3b8e105

Contents?: true

Size: 1.02 KB

Versions: 4

Compression:

Stored size: 1.02 KB

Contents

class Contact < ActiveRecord::Base
    has_and_belongs_to_many :contact_purposes
    belongs_to :party
    belongs_to :contact_mechanism, :polymorphic => true
  
    #rather than carry our own description for the abstract -contact-, we'll
    #delegate that call to the implementor of the -contact_mechanism- interface

    def description
        @description = contact_mechanism.description
    end

    def description=(d)
        @description=d
    end

    #delegate our need to provide a label to scaffolds to the implementor of
    #the -contact_mechanism- interface.

    def to_label
        "#{contact_mechanism.description}"
    end

    def summary_line
        "#{contact_mechanism.summary_line}"
    end

    # return first contact purpose
    def purpose
        contact_purposes.first.description
    end

    # return all contact purposes as an array
    def purposes
    	p = []
      contact_purposes.each do |cp|
      	p << cp.description
      end

      return p
    end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
erp_base_erp_svcs-3.0.4 app/models/contact.rb
erp_base_erp_svcs-3.0.3 app/models/contact.rb
erp_base_erp_svcs-3.0.2 app/models/contact.rb
erp_base_erp_svcs-3.0.1 app/models/contact.rb