Skip to content
marcinbunsch edited this page Sep 14, 2010 · 2 revisions

Tags are accessed via the Things::Tag class.

Collections

Currently there are no options for fetching a collection of Tags

Create

If you want to create a new Tag, you simple create a new instance of the Things::Tag class, supplying the parameters:

Things::Tag.new(:name => 'important')

When you’re ready to send it to Things, simply call the save method on the instance:

tag = Things::Tag.new(:name => 'important')
tag.save # the Tag will appear in Tag tag

If you want to send the Tag to Things during the instantiation process, simply call create:

Things::Tag.create(:name => 'important') # the Tag will appear in the tag list

Read

Things::Tag has a few useful methods if you want to fetch a single Tag.

The smartest is the Things::Tag.find method, which will accept either a name or an id.

Things::Tag.find('important') # => #<Things::Tag:0x115dd84>
Things::Tag.find('11111111-1111-1111-1111-111111111111') # => #<Things::Tag:0x115dd84>

If you want a more targeted approach, you can use Things::Tag.find_by_name or Things::Tag.find_by_id

Update

To update a Tag, you need to fetch it, change the desired properties and save it. The following example illustrates this:

tag = Things::Tag.find('important') # => #<Things::Tag:0x115dd84>
tag.name = 'Not so Secret Tag'  
tag.save

When you open up a Things window, you’ll notice that the name has changed.

Delete

To delete a Tag, simply call the delete method. The Tag will be moved to Trash.

tag = Things::Tag.find('important') # => #<Things::Tag:0x115dd84>
tag.delete

Clone this wiki locally