Module: Highrise::Taggable

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

Instance Method Summary collapse

Instance Method Details

#tag!(tag_name) ⇒ Object



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

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

#tagsObject



4
5
6
7
8
9
10
# File 'lib/highrise/taggable.rb', line 4

def tags
  unless self.attributes.has_key?("tags")
    person_or_company = self.class.find(id)
    self.attributes["tags"] = person_or_company.attributes.has_key?("tags") ? person_or_company.tags : []
  end
  self.attributes["tags"]
end

#untag!(tag_name) ⇒ Object



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

def untag!(tag_name)
  to_delete = self.tags.find{|tag| tag.attributes['name'] == tag_name} unless tag_name.blank?
  self.untag_id!(to_delete.attributes['id']) unless to_delete.nil?
end