Class: XPlanner::Story

Inherits:
ModelHelper show all
Extended by:
AttrAccessorWithDirtyBit
Defined in:
lib/models/story.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(story) ⇒ Story

Returns a new instance of Story.



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

def initialize( story )
  @dirty_bit = false

  @actual_hours             = story[:actual_hours]
  @adjusted_estimated_hours = story[:adjusted_estimated_hours]
  @completed                = story[:completed]
  @customer_id              = story[:customer_id]
  @description              = story[:description]
  @disposition_name         = story[:disposition_name]
  @estimated_hours          = story[:estimated_hours]
  @estimated_original_hours = story[:estimated_original_hours]
  @id                       = story[:id]
  @iteration_id             = story[:iteration_id]
  @last_update_time         = Story.parse_date story[:last_update_time]
  @name                     = story[:name]
  @postponed_hours          = story[:postponed_hours]
  @priority                 = story[:priority]
  @remaining_hours          = story[:remaining_hours]
  @tracker_id               = story[:tracker_id]
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



21
22
23
# File 'lib/models/story.rb', line 21

def id
  @id
end

Class Method Details

.all(iteration_id) ⇒ Object



45
46
47
48
49
50
# File 'lib/models/story.rb', line 45

def self.all( iteration_id )
  rpc = :get_user_stories
  payload = { :containerId => iteration_id }
  path = [:get_user_stories_response, :get_user_stories_return, :get_user_stories_return]
  fetch_from_remote( rpc, payload, path, Story )
end

.create(iteration_id, name, description, disposition = 'planned', completed = 'false', priority = '4') ⇒ Object



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

def self.create( iteration_id, name, description, disposition = 'planned', completed = 'false', priority = '4' )
  rpc = :add_user_story
  payload = { :userStoryData =>{
      :iteration_id =>iteration_id, 
      :name => name, 
      :description => description,
      :disposition_name => disposition,
      :completed => completed,
      :priority => priority
    } 
  }
  path = [:add_user_story_response, :add_user_story_return]
  fetch_from_remote( rpc, payload, path, Story )
end

.delete(id) ⇒ Object



74
75
76
77
78
# File 'lib/models/story.rb', line 74

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

.retrieve(story_id) ⇒ Object



52
53
54
55
56
57
# File 'lib/models/story.rb', line 52

def self.retrieve( story_id )
  rpc = :get_user_story
  payload = { :userStoryId => story_id }
  path = [:get_user_story_response, :get_user_story_return]
  fetch_from_remote( rpc, payload, path, Story )
end

Instance Method Details

#deleteObject



80
81
82
# File 'lib/models/story.rb', line 80

def delete
  Story.delete( @id )
end

#saveObject



84
85
86
87
88
# File 'lib/models/story.rb', line 84

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