-
Notifications
You must be signed in to change notification settings - Fork 2
Things::Tag
Tags are accessed via the Things::Tag class.
Currently there are no options for fetching a collection of Tags
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 tagIf 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 listThings::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
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.saveWhen you open up a Things window, you’ll notice that the name has changed.
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