Sha256: 08fa03226dcaa89a132a21490f5f66683930e2d02274d30180ec91d5727b7ff3

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

module Highrise
  class Person < Subject
    include Pagination
    include Taggable
    include Searchable
    include HasSubjectData
    
    def company
      Company.find(company_id) if company_id
    end
  
    def name
      "#{first_name rescue ''} #{last_name rescue ''}".strip
    end
    
    def address
      contact_data.addresses.first
    end
    
    def web_address
      contact_data.web_addresses.first
    end
    
    def label
      'Party'
    end
    
    def phone_number
      contact_data.phone_numbers.first.number rescue nil
    end
    
    def email_valid?
      !!(email_address && (email_address =~ RFC822::EmailAddress))
    end
    
    def email_address
      contact_data.email_addresses.first.address rescue nil
    end
    alias :email :email_address
    
    def tagged? name
     tags.any?{ | tag | tag['name'].to_s == name}  
    end
    
    def self.tagged_with_name(tag_name)
      tagged_with_id((Tag.find_by_name(tag_name)).id)
    end
    
    def self.tagged_with_id id
     find_all_across_pages(:from => "/tags/#{id}.xml").select do |obj|
        obj.kind_of?(Person)
      end
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
peterosullivan-highrise-3.0.7 lib/highrise/person.rb