Class: LiquidPlanner::Resources::Leaf

Inherits:
Treeitem show all
Includes:
Movable, Packageable
Defined in:
lib/liquidplanner/resources/leaf.rb

Direct Known Subclasses

Event, Milestone, Task

Constant Summary collapse

TRACK_TIME_KEYS =
[ :work, :activity_id, :member_id, :low, :high, :is_done, :done_on, :work_performed_on, :comment ].freeze

Instance Method Summary collapse

Methods included from Packageable

#package_after, #package_before

Methods included from MoveOrPackage

#move_or_package

Methods included from Movable

#move_after, #move_before

Methods inherited from Treeitem

#activities, #attach_document, #client, #comments, #documents, #estimates, #item_collection, #links, #note, #package, #parent, #project, #workspace_id

Methods inherited from LiquidPlannerResource

#get_raw, #load

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class LiquidPlanner::LiquidPlannerResource

Instance Method Details

#track_time(options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/liquidplanner/resources/leaf.rb', line 11

def track_time( options={} )
  options.assert_valid_keys( *TRACK_TIME_KEYS )
  request_body = options.to_json
  # ActiveResource post() by default:
  #   response = post(:track_time, {}, request_body) 
  # will set this route with 'new': /api/workspaces/36/tasks/new/activities.json
  # it's because of how it sets @persisted = true by default, calling custom_method_new_element_url()
  # what we want is: /api/workspaces/36/tasks/:id/activities.json, which is accomplished here:
  response = connection.post(custom_method_element_url(:track_time, options), request_body)
  load( self.class.format.decode( response.body ) )
end