Class: YouTrack::Client::Issue

Inherits:
Model
  • Object
show all
Defined in:
lib/you_track/client/models/issue.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Model

ms_time, #require_admin!

Instance Attribute Details

#permitted_groupObject

Returns the value of attribute permitted_group.



21
22
23
# File 'lib/you_track/client/models/issue.rb', line 21

def permitted_group
  @permitted_group
end

Instance Method Details

#comment(comment) ⇒ Object



30
31
32
33
# File 'lib/you_track/client/models/issue.rb', line 30

def comment(comment)
  service.apply_issue_command("id" => self.identity, "comment" => comment)
  comments.detect { |c| c.text == comment }
end

#commentsObject



26
27
28
# File 'lib/you_track/client/models/issue.rb', line 26

def comments
  service.comments.load(service.get_issue_comments(self.identity).body)
end

#projectObject



48
49
50
51
52
# File 'lib/you_track/client/models/issue.rb', line 48

def project
  requires :project_id

  service.projects.get(self.project_id)
end

#project=(project) ⇒ Object



44
45
46
# File 'lib/you_track/client/models/issue.rb', line 44

def project=(project)
  self.project_id = (project.is_a?(YouTrack::Client::Project) ? project.identity : project)
end

#saveObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/you_track/client/models/issue.rb', line 54

def save
  if new_record?
    if collection
      self.project_id ||= collection.project_id
    end

    requires :summary, :project_id

    response = service.create_issue(
      "project"         => self.project_id,
      "summary"         => self.summary,
      "description"     => self.description,
      "attachments"     => self.attachments,
      "permittedGroups" => self.permitted_group,
    )

    merge_attributes(
      :id => File.basename(response.headers["Location"]),
    )

    reload
  else
    requires :identity

    service.update_issue(
      "id"          => self.identity,
      "summary"     => self.summary,
      "description" => self.description,
    )
    self.reload
  end
end

#stateObject



35
36
37
# File 'lib/you_track/client/models/issue.rb', line 35

def state
  custom_fields["State"]
end

#state=(new_state) ⇒ Object



39
40
41
42
# File 'lib/you_track/client/models/issue.rb', line 39

def state=(new_state)
  service.apply_issue_command("id" => self.identity, "command" => "State #{new_state}")
  self.reload
end