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

Areas are accessed via the Things::Area class.

Collections

Currently there are no options for fetching a collection of Areas

Create

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

Things::Area.new(:name => 'Car')

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

area = Things::Area.new(:name => 'Car')
area.save # the Area will appear in Area area

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

Things::Area.create(:name => 'Car') # the Area will appear in the area list

Read

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

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

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

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

Update

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

area = Things::Area.find('Car') # => #<Things::Area:0x115dd84>
area.name = 'Not so Secret Area'  
area.save

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

Delete

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

area = Things::Area.find('Car') # => #<Things::Area:0x115dd84>
area.delete
Clone this wiki locally