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.



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

def permitted_group
  @permitted_group
end

Instance Method Details

#assigneeObject



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

def assignee
  if user_id = self.custom_fields["Assignee"]
    service.users.new(
      service.get_user(user_id).body
    )
  end
end

#assignee=(user) ⇒ Object



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

def assignee=(user)
  user_id = user.is_a?(YouTrack::Client::User) ? user.identity : user
  service.apply_issue_command("id" => self.identity, "command" => "Assignee #{user_id}")
  self.reload
end

#comment(comment) ⇒ Object



28
29
30
31
# File 'lib/you_track/client/models/issue.rb', line 28

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

#commentsObject



24
25
26
# File 'lib/you_track/client/models/issue.rb', line 24

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

#projectObject



64
65
66
67
68
# File 'lib/you_track/client/models/issue.rb', line 64

def project
  requires :project_id

  service.projects.get(self.project_id)
end

#project=(project) ⇒ Object



60
61
62
# File 'lib/you_track/client/models/issue.rb', line 60

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

#resolved?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/you_track/client/models/issue.rb', line 47

def resolved?
  !! self.resolved
end

#saveObject



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/you_track/client/models/issue.rb', line 70

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



51
52
53
# File 'lib/you_track/client/models/issue.rb', line 51

def state
  custom_fields["State"]
end

#state=(new_state) ⇒ Object



55
56
57
58
# File 'lib/you_track/client/models/issue.rb', line 55

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