Class: PivotalTracker::Task

Inherits:
Object
  • Object
show all
Includes:
HappyMapper, Validation
Defined in:
lib/pivotal-tracker/task.rb,
lib/pivotal-tracker/task.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Validation

#create_with_validations, #errors, included, #update_with_validations

Constructor Details

#initialize(attributes = {}) ⇒ Task

Returns a new instance of Task.



22
23
24
25
26
27
28
29
30
# File 'lib/pivotal-tracker/task.rb', line 22

def initialize(attributes={})
  if attributes[:owner]
    self.story = attributes.delete(:owner)
    self.project_id = self.story.project_id
    self.story_id = self.story.id
  end

  update_attributes(attributes)
end

Instance Attribute Details

#project_idObject

Returns the value of attribute project_id.



13
14
15
# File 'lib/pivotal-tracker/task.rb', line 13

def project_id
  @project_id
end

#story_idObject

Returns the value of attribute story_id.



13
14
15
# File 'lib/pivotal-tracker/task.rb', line 13

def story_id
  @story_id
end

Class Method Details

.all(story, options = {}) ⇒ Object



6
7
8
9
10
# File 'lib/pivotal-tracker/task.rb', line 6

def all(story, options={})
  tasks = parse(Client.connection["/projects/#{story.project_id}/stories/#{story.id}/tasks"].get)
  tasks.each { |t| t.project_id, t.story_id = story.project_id, story.id }
  return tasks
end

Instance Method Details

#createObject



32
33
34
35
# File 'lib/pivotal-tracker/task.rb', line 32

def create
  response = Client.connection["/projects/#{project_id}/stories/#{story_id}/tasks"].post(self.to_xml, :content_type => 'application/xml')
  return Task.parse(response)
end

#deleteObject



43
44
45
# File 'lib/pivotal-tracker/task.rb', line 43

def delete
  Client.connection["/projects/#{project_id}/stories/#{story_id}/tasks/#{id}"].delete
end

#update(attr = {}) ⇒ Object



37
38
39
40
41
# File 'lib/pivotal-tracker/task.rb', line 37

def update(attr = {})
  update_attributes(attr)
  response = Client.connection["/projects/#{project_id}/stories/#{story_id}/tasks/#{id}"].put(self.to_xml, :content_type => 'application/xml')
  return Task.parse(response)
end