Class: PivotalTracker::Task
- Inherits:
-
Object
- Object
- PivotalTracker::Task
- Includes:
- HappyMapper, Validation
- Defined in:
- lib/pivotal-tracker/task.rb,
lib/pivotal-tracker/task.rb
Instance Attribute Summary collapse
-
#project_id ⇒ Object
Returns the value of attribute project_id.
-
#story_id ⇒ Object
Returns the value of attribute story_id.
Class Method Summary collapse
Instance Method Summary collapse
- #create ⇒ Object
- #delete ⇒ Object
-
#initialize(attributes = {}) ⇒ Task
constructor
A new instance of Task.
- #update(attr = {}) ⇒ Object
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_id ⇒ Object
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_id ⇒ Object
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, ={}) 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
#create ⇒ Object
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 |
#delete ⇒ Object
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 |