Class: XPlanner::Task

Inherits:
ModelHelper show all
Extended by:
AttrAccessorWithDirtyBit
Defined in:
lib/models/task.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from AttrAccessorWithDirtyBit

dirty_accessor

Methods inherited from ModelHelper

base_url, base_url=, check_client_initialised, #check_client_initialised, #create_payload, fetch_from_remote, #hashify, parse_date, remote_delete, #remote_update, soap_client, soap_client=

Constructor Details

#initialize(task) ⇒ Task

Returns a new instance of Task.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/models/task.rb', line 23

def initialize( task )
  @dirty_bit = false

  @acceptor_id              = task[:acceptor_id]
  @actual_hours             = task[:actual_hours]
  @adjusted_estimated_hours = task[:adjusted_estimated_hours]
  @completed                = task[:completed]
  @created_date             = Task.parse_date task[:created_date]
  @description              = task[:description]
  @disposition_name         = task[:disposition_name]
  @estimated_hours          = task[:estimated_hours]
  @estimated_original_hours = task[:estimated_original_hours]
  @last_update_time         = task[:last_update_time]
  @name                     = task[:name]
  @remaining_hours          = task[:remaining_hours]
  @story_id                 = task[:story_id]
  @type                     = task[:type]
  @id                       = task[:id]
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



20
21
22
# File 'lib/models/task.rb', line 20

def id
  @id
end

Class Method Details

.all(story_id) ⇒ Object



43
44
45
46
47
48
# File 'lib/models/task.rb', line 43

def self.all( story_id )
  rpc = :get_tasks
  payload = { :containerId => story_id }
  path = [:get_taskss_response, :get_tasks_return, :get_tasks_return]
  fetch_from_remote( rpc, payload, path, Task )
end

.create(story_id, name, description, type = 'Task', disposition = 'planned', completed = 'false') ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/models/task.rb', line 57

def self.create( story_id, name, description, type = 'Task', disposition = 'planned', completed = 'false' )
  rpc = :add_task
  payload = { :taskData => {
      :story_id => story_id, 
      :name => name, 
      :description => description,
      :disposition_name => disposition,
      :completed => completed,
      :type => type,
      :created_date => DateTime.now
    } 
  }
  path = [:add_task_response, :add_task_return]
  fetch_from_remote( rpc, payload, path, Task )
end

.delete(id) ⇒ Object



73
74
75
76
77
# File 'lib/models/task.rb', line 73

def self.delete( id )
  rpc = :remove_task
  payload = { :id => id }
  remote_delete( rpc, payload )
end

.retrieve(task_id) ⇒ Object



50
51
52
53
54
55
# File 'lib/models/task.rb', line 50

def self.retrieve( task_id )
  rpc = :get_task
  payload = { :taskId => task_id }
  path = [:get_task_response, :get_task_return]
  fetch_from_remote( rpc, payload, path, Task )
end

Instance Method Details

#deleteObject



79
80
81
# File 'lib/models/task.rb', line 79

def delete
  Task.delete( @id )
end

#saveObject



83
84
85
86
87
# File 'lib/models/task.rb', line 83

def save
  rpc = :update
  payload = { :taskData => create_payload }
  remote_update( rpc, payload )
end