Module: Highrise::Taggable

Included in:
Company, Person
Defined in:
lib/highrise/taggable.rb

Instance Method Summary collapse

Instance Method Details

#get_documentObject



27
28
29
30
# File 'lib/highrise/taggable.rb', line 27

def get_document
  @curl_helper ||= CurlHelper.new
  @doc = @curl_helper.get_document_from_id("#{self.class.collection_name}/#{self.id}")
end

#tag!(tag_name) ⇒ Object



6
7
8
# File 'lib/highrise/taggable.rb', line 6

def tag!(tag_name)
  self.post(:tags, :name => tag_name) unless tag_name.blank?
end

#tagsObject



19
20
21
22
23
24
25
# File 'lib/highrise/taggable.rb', line 19

def tags      
  tags = []
  get_document.search("#show_tags a").each{ |a|
   tags << Highrise::Tag.new(:id => a['href'].gsub(/.*\//, ''), :name => a.inner_html) if a['class'] == "grey tag"
  }
  tags
end

#untag!(tag_name) ⇒ Object



10
11
12
13
# File 'lib/highrise/taggable.rb', line 10

def untag!(tag_name)
  to_delete = self.tags.find{|t| t.name==tag_name} unless tag_name.blank?
  self.untag_id!(to_delete.id) unless to_delete.nil?
end

#untag_id!(tag_id) ⇒ Object



15
16
17
# File 'lib/highrise/taggable.rb', line 15

def untag_id!(tag_id)
  self.delete("tags/#{tag_id}")
end