Class: Jiralicious::Issue::Comment

Inherits:
Base
  • Object
show all
Defined in:
lib/jiralicious/issue/comment.rb

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, #reload

Methods included from Parsers::FieldParser

#parse!

Constructor Details

#initialize(decoded_json = nil, default = nil, &blk) ⇒ Comment

Returns a new instance of Comment.



8
9
10
11
12
13
14
# File 'lib/jiralicious/issue/comment.rb', line 8

def initialize(decoded_json = nil, default = nil, &blk)
  if (decoded_json != nil)
    properties_from_hash(decoded_json)
    super(decoded_json)
    parse!(decoded_json)
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Jiralicious::Base

Instance Attribute Details

#jira_keyObject

Returns the value of attribute jira_key.



6
7
8
# File 'lib/jiralicious/issue/comment.rb', line 6

def jira_key
  @jira_key
end

Class Method Details

.add(comment, key) ⇒ Object



31
32
33
# File 'lib/jiralicious/issue/comment.rb', line 31

def add(comment, key)
  fetch({:method => :post, :body => comment, :parent => parent_name, :parent_key => key})
end

.edit(comment, key, id) ⇒ Object



35
36
37
# File 'lib/jiralicious/issue/comment.rb', line 35

def edit(comment, key, id)
  fetch({:method => :put, :key => id, :body => comment, :parent => parent_name, :parent_key => key})
end

.find_by_key(key, options = {}) ⇒ Object



17
18
19
20
21
22
# File 'lib/jiralicious/issue/comment.rb', line 17

def find_by_key(key, options = {})
  response = fetch({:parent => parent_name, :parent_key => key})
  a = new(response)
  a.jira_key = key
  return a
end

.find_by_key_and_id(key, id, options = {}) ⇒ Object



24
25
26
27
28
29
# File 'lib/jiralicious/issue/comment.rb', line 24

def find_by_key_and_id(key, id, options = {})
  response = fetch({:parent => parent_name, :parent_key => key, :key => id})
  a = new(response)
  a.jira_key = key
  return a
end

.remove(key, id) ⇒ Object



39
40
41
42
# File 'lib/jiralicious/issue/comment.rb', line 39

def remove(key, id)
  fetch({:method => :delete, :body_to_params => true, :key => id, :parent => parent_name, :parent_key => key})

end

Instance Method Details

#add(comment) ⇒ Object



49
50
51
# File 'lib/jiralicious/issue/comment.rb', line 49

def add(comment)
  self.class.add(comment, @jira_key)
end

#edit(comment) ⇒ Object



53
54
55
# File 'lib/jiralicious/issue/comment.rb', line 53

def edit(comment)
  self.class.edit(comment, @jira_key, self.id)
end

#find_by_id(id, options = {}) ⇒ Object



45
46
47
# File 'lib/jiralicious/issue/comment.rb', line 45

def find_by_id(id, options = {})
  self.class.find_by_key_and_id(@jira_key, id)
end

#remove(id = self.id) ⇒ Object



57
58
59
# File 'lib/jiralicious/issue/comment.rb', line 57

def remove(id = self.id)
  self.class.remove(@jira_key, id)
end