Class: TrackerApi::Resources::Story
- Includes:
- TrackerApi::Resources::Shared::Base
- Defined in:
- lib/tracker_api/resources/story.rb
Defined Under Namespace
Classes: UpdateRepresenter
Instance Method Summary collapse
-
#activity(params = {}) ⇒ Array[Activity]
Provides a list of all the activity performed on the story.
-
#add_label(label) ⇒ Object
Adds a new label to the story.
-
#add_owner(owner) ⇒ Object
Adds a new owner to the story.
-
#comments(reload: false) ⇒ Array[Comment]
Provides a list of all the comments on the story.
-
#create_comment(params) ⇒ Comment
Newly created Comment.
-
#create_task(params) ⇒ Task
Newly created Task.
-
#label_list ⇒ String
Comma separated list of labels.
-
#owners(params = {}) ⇒ Array[Person]
Provides a list of all the owners of the story.
-
#project_id ⇒ Object
Returns the story’s original (“undirtied”) project_id.
-
#save ⇒ Object
Save changes to an existing Story.
-
#tasks(params = {}) ⇒ Array[Task]
Provides a list of all the tasks on the story.
-
#transitions(params = {}) ⇒ Array[StoryTransition]
Provides a list of all the transitions of the story.
Methods included from TrackerApi::Resources::Shared::Base
Instance Method Details
#activity(params = {}) ⇒ Array[Activity]
Provides a list of all the activity performed on the story.
117 118 119 |
# File 'lib/tracker_api/resources/story.rb', line 117 def activity(params = {}) Endpoints::Activity.new(client).get_story(project_id, id, params) end |
#add_label(label) ⇒ Object
Adds a new label to the story.
87 88 89 90 91 92 93 94 95 96 |
# File 'lib/tracker_api/resources/story.rb', line 87 def add_label(label) new_label = if label.kind_of?(String) Label.new(name: label) else label end # Use attribute writer to get coercion and dirty tracking. self.labels = (labels ? labels.dup : []).push(new_label).uniq end |
#add_owner(owner) ⇒ Object
Adds a new owner to the story.
101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/tracker_api/resources/story.rb', line 101 def add_owner(owner) owner_id = if owner.kind_of?(Fixnum) owner_id = owner else raise ArgumentError, 'Valid Person expected.' unless owner.instance_of?(Resources::Person) owner_id = owner.id end # Use attribute writer to get coercion and dirty tracking. self.owner_ids = (owner_ids ? owner_ids.dup : []).push(owner_id).uniq end |
#comments(reload: false) ⇒ Array[Comment]
Provides a list of all the comments on the story.
125 126 127 128 129 130 131 |
# File 'lib/tracker_api/resources/story.rb', line 125 def comments(reload: false) if !reload && @comments.present? @comments else @comments = Endpoints::Comments.new(client).get(project_id, id) end end |
#create_comment(params) ⇒ Comment
Returns newly created Comment.
188 189 190 191 192 193 |
# File 'lib/tracker_api/resources/story.rb', line 188 def create_comment(params) files = params.delete(:files) comment = Endpoints::Comment.new(client).create(project_id, id, params) comment.(files: files) if files.present? comment end |
#create_task(params) ⇒ Task
Returns newly created Task.
182 183 184 |
# File 'lib/tracker_api/resources/story.rb', line 182 def create_task(params) Endpoints::Task.new(client).create(project_id, id, params) end |
#label_list ⇒ String
Returns Comma separated list of labels.
77 78 79 80 81 82 |
# File 'lib/tracker_api/resources/story.rb', line 77 def label_list @label_list ||= begin return if labels.nil? labels.collect(&:name).join(',') end end |
#owners(params = {}) ⇒ Array[Person]
Provides a list of all the owners of the story.
149 150 151 152 153 154 155 |
# File 'lib/tracker_api/resources/story.rb', line 149 def owners(params = {}) if params.blank? && @owners.present? @owners else @owners = Endpoints::StoryOwners.new(client).get(project_id, id, params) end end |
#project_id ⇒ Object
Returns the story’s original (“undirtied”) project_id
172 173 174 175 176 177 178 |
# File 'lib/tracker_api/resources/story.rb', line 172 def project_id if dirty_attributes.key?(:project_id) original_attributes[:project_id] else @project_id end end |
#save ⇒ Object
Save changes to an existing Story.
196 197 198 199 200 201 |
# File 'lib/tracker_api/resources/story.rb', line 196 def save raise ArgumentError, 'Can not update a story with an unknown project_id.' if project_id.nil? return self unless dirty? Endpoints::Story.new(client).update(self, UpdateRepresenter.new(Story.new(self.dirty_attributes))) end |
#tasks(params = {}) ⇒ Array[Task]
Provides a list of all the tasks on the story.
137 138 139 140 141 142 143 |
# File 'lib/tracker_api/resources/story.rb', line 137 def tasks(params = {}) if params.blank? && @tasks.present? @tasks else @tasks = Endpoints::Tasks.new(client).get(project_id, id, params) end end |
#transitions(params = {}) ⇒ Array[StoryTransition]
Provides a list of all the transitions of the story.
161 162 163 164 165 166 167 |
# File 'lib/tracker_api/resources/story.rb', line 161 def transitions(params = {}) if params.blank? && @transitions.present? @transitions else @transitions = Endpoints::StoryTransitions.new(client).get(project_id, id, params) end end |