Class: TFS::WorkItems

Inherits:
Queryable show all
Defined in:
lib/tfs/work_items.rb

Constant Summary collapse

InvalidRecord =
Class.new(StandardError)
REQUIRED_PARAMS =
[
  "Title",
  "Type",
  "Project",
  "Description"
]

Constants inherited from Queryable

Queryable::RecordNotFound

Constants included from ClassHelpers

ClassHelpers::SPECIAL_CASES

Class Method Summary collapse

Methods inherited from Queryable

all, inherited, odata_query

Methods included from ClassHelpers

#base_class, #method_name_from_class, #odata_class_from_method_name

Class Method Details

.find(id) ⇒ Object

Changeset can be found by id alone

TFS::Changeset.find(123)


17
18
19
# File 'lib/tfs/work_items.rb', line 17

def find(id)
  TFS.workitems(id).run.first
end

.save(item) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/tfs/work_items.rb', line 21

def save(item)
  REQUIRED_PARAMS.each do |param|
    raise InvalidRecord, "Missing required parameter '#{param}'" if item.send(param).nil?
  end

  client.AddToWorkItems(item)
  item = client.save_changes
  item.first
end

.update(item) ⇒ Object



31
32
33
34
# File 'lib/tfs/work_items.rb', line 31

def update(item)
  client.update_object(item)
  client.save_changes
end