Sha256: e00735d24b3efad87ef6f1e15391b2a06ac206052684191c0632ffb7db68192f

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

module Highrise
  class Person < Subject
    include Pagination
  
    def self.find_all_across_pages_since(time)
      find_all_across_pages(:params => { :since => time.to_s(:db).gsub(/[^\d]/, '') })
    end
  
    def company
      Company.find(company_id) if company_id
    end
  
    def name
      "#{first_name} #{last_name}".strip
    end
    
    def tags
      # thanks for the user Inka, http://forum.37signals.com/highrise/forums/15/topics/1312?page=2
      usertags = Array.new
      codigo = self.id
      tags = Highrise::Tag.find(:all)
      tags.each do |tag|
        id = tag.attributes["id"]
        users = Highrise::Tag.find(:all, :from => "/tags/#{id}").to_xml
        if users.scan(/#{codigo}/).size > 0
          usertags << tag.attributes["name"]
        end
      end
      usertags
    end

    def tag!(tag_name)
      # thanks for the user Inka, http://forum.37signals.com/highrise/forums/15/topics/1312?page=2
      self.post(:tags, :name => tag_name) unless tag_name.blank?
      true
    end
  
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
slainer68-highrise-0.6.1 lib/highrise/person.rb
slainer68-highrise-0.6 lib/highrise/person.rb