-
Notifications
You must be signed in to change notification settings - Fork 2
Things::Area
Areas are accessed via the Things::Area class.
Currently there are no options for fetching a collection of Areas
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
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
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.
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