Sha256: d72c970210ca2e993de629212bd3814fe3b6d022c8b15940d230317a88deea54

Contents?: true

Size: 544 Bytes

Versions: 1

Compression:

Stored size: 544 Bytes

Contents

module Highrise
  module Taggable        
    def tags
      self.attributes.has_key?("tags") ? self.attributes["tags"] : self.get(:tags)
    end

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

    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
    protected
    def untag_id!(tag_id)
      self.delete("tags/#{tag_id}")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
highrise-3.2.1 lib/highrise/taggable.rb