Class: Jiralicious::Issue
- Inherits:
-
Base
- Object
- Hashie::Trash
- Base
- Jiralicious::Issue
show all
- Defined in:
- lib/jiralicious/issue.rb,
lib/jiralicious/issue/fields.rb,
lib/jiralicious/issue/comment.rb,
lib/jiralicious/issue/watchers.rb,
lib/jiralicious/issue/transitions.rb
Defined Under Namespace
Classes: Comment, Fields, Transitions, Watchers
Instance Attribute Summary collapse
Attributes inherited from Base
#loaded
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#all, #endpoint_name, endpoint_name, fetch, find, find_all, handler, #loaded?, #method_missing, #numeric?, parent_name, #parent_name, #properties_from_hash
#parse!
Constructor Details
#initialize(decoded_json = nil, default = nil, &blk) ⇒ Issue
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/jiralicious/issue.rb', line 18
def initialize(decoded_json = nil, default = nil, &blk)
@loaded = false
if (!decoded_json.nil?)
super(decoded_json)
parse!(decoded_json["fields"])
if default.nil?
@fields = Fields.new(self['fields']) if self['fields']
@comments = Comment.find_by_key(self.jira_key)
@watchers = Watchers.find_by_key(self.jira_key)
@loaded = true
end
end
@fields = Fields.new if @fields.nil?
@comments = Comment.new if @comments.nil?
@watchers = Watchers.new if @watchers.nil?
@createmeta = nil
@editmeta = nil
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Jiralicious::Base
Instance Attribute Details
Returns the value of attribute comments.
12
13
14
|
# File 'lib/jiralicious/issue.rb', line 12
def
@comments
end
|
Returns the value of attribute createmeta.
14
15
16
|
# File 'lib/jiralicious/issue.rb', line 14
def createmeta
@createmeta
end
|
Returns the value of attribute editmeta.
15
16
17
|
# File 'lib/jiralicious/issue.rb', line 15
def editmeta
@editmeta
end
|
#fields ⇒ Object
Returns the value of attribute fields.
11
12
13
|
# File 'lib/jiralicious/issue.rb', line 11
def fields
@fields
end
|
#watchers ⇒ Object
Returns the value of attribute watchers.
13
14
15
|
# File 'lib/jiralicious/issue.rb', line 13
def watchers
@watchers
end
|
Class Method Details
.assignee(name, key) ⇒ Object
59
60
61
62
|
# File 'lib/jiralicious/issue.rb', line 59
def assignee(name, key)
name = {"name" => name} if name.is_a? String
fetch({:method => :put, :key => "#{key}/assignee", :body => name})
end
|
.create(issue) ⇒ Object
64
65
66
|
# File 'lib/jiralicious/issue.rb', line 64
def create(issue)
fetch({:method => :post, :body => issue})
end
|
76
77
78
79
|
# File 'lib/jiralicious/issue.rb', line 76
def createmeta(projectkeys, issuetypeids = nil)
response = fetch({:body_to_params => true, :key => "createmeta", :body => {:expand => "projects.issuetypes.fields.", :projectKeys => projectkeys, :issuetypeIds => issuetypeids}})
return Field.new(response.parsed_response)
end
|
81
82
83
84
85
|
# File 'lib/jiralicious/issue.rb', line 81
def editmeta(key)
response = fetch({:key => "#{key}/editmeta"})
response.parsed_response["key"] = key
Field.new(response.parsed_response)
end
|
.get_transitions(transitions_url) ⇒ Object
87
88
89
|
# File 'lib/jiralicious/issue.rb', line 87
def get_transitions(transitions_url)
Jiralicious.session.request(:get, transitions_url, :handler => handler)
end
|
.remove(key, options = {}) ⇒ Object
68
69
70
|
# File 'lib/jiralicious/issue.rb', line 68
def remove(key, options = {})
fetch({:method => :delete, :body_to_params => true, :key => key, :body => options})
end
|
.transition(transitions_url, data) ⇒ Object
91
92
93
94
95
|
# File 'lib/jiralicious/issue.rb', line 91
def transition(transitions_url, data)
Jiralicious.session.request(:post, transitions_url,
:handler => handler,
:body => data.to_json)
end
|
.update(issue, key) ⇒ Object
72
73
74
|
# File 'lib/jiralicious/issue.rb', line 72
def update(issue, key)
fetch({:method => :put, :key => key, :body => issue})
end
|
Instance Method Details
#load(decoded_hash, default = nil) ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/jiralicious/issue.rb', line 37
def load(decoded_hash, default = nil)
decoded_hash.each do |k,v|
self[:"#{k}"] = v
end
if default.nil?
parse!(self['fields'])
@fields = Fields.new(self['fields']) if self['fields']
@comments = Comment.find_by_key(self.jira_key)
@watchers = Watchers.find_by_key(self.jira_key)
@loaded = true
else
parse!(decoded_hash)
end
end
|
#reload ⇒ Object
52
53
54
|
# File 'lib/jiralicious/issue.rb', line 52
def reload
load(self.class.find(self.jira_key, {:reload => true}).parsed_response)
end
|
#remove(options = {}) ⇒ Object
104
105
106
|
# File 'lib/jiralicious/issue.rb', line 104
def remove(options = {})
self.class.remove(self.jira_key, options)
end
|
#save ⇒ Object
122
123
124
125
126
127
128
129
130
131
|
# File 'lib/jiralicious/issue.rb', line 122
def save
if loaded?
self.class.update(@fields.format_for_update, self.jira_key)
key = self.jira_key
else
response = self.class.create(@fields.format_for_create)
key = response.parsed_response['key']
end
load(self.class.find(key, {:reload => true}).parsed_response)
end
|
#set_assignee(name) ⇒ Object
100
101
102
|
# File 'lib/jiralicious/issue.rb', line 100
def set_assignee(name)
self.class.assignee(name, self.jira_key)
end
|