Class: Jiralicious::Issue::Watchers
- Defined in:
- lib/jiralicious/issue/watchers.rb
Overview
The Watchers class is used to manage the watchers on an issue.
Instance Attribute Summary collapse
-
#jira_key ⇒ Object
Holds the Issue Key.
Attributes inherited from Base
Class Method Summary collapse
-
.add(name, key) ⇒ Object
Adds a new Watcher to the Issue.
-
.find_by_key(key) ⇒ Object
Finds all watchers based on the provided Issue Key.
-
.remove(name, key) ⇒ Object
Removes/Deletes a Watcher from the Issue.
Instance Method Summary collapse
-
#add(name) ⇒ Object
Adds a new Watcher to the Issue.
-
#find ⇒ Object
Finds all watchers based on the provided Issue Key.
-
#initialize(decoded_json = nil) ⇒ Watchers
constructor
Initialization Method.
-
#remove(name) ⇒ Object
Removes/Deletes a Watcher from the Issue.
Methods inherited from Base
#all, #endpoint_name, endpoint_name, fetch, find, find_all, handler, issueKey_test, #loaded?, #method_missing, #numeric?, parent_name, #parent_name, #properties_from_hash, #reload
Methods included from Parsers::FieldParser
Constructor Details
#initialize(decoded_json = nil) ⇒ Watchers
Initialization Method
17 18 19 20 21 22 23 |
# File 'lib/jiralicious/issue/watchers.rb', line 17 def initialize(decoded_json = nil) 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_key ⇒ Object
Holds the Issue Key
12 13 14 |
# File 'lib/jiralicious/issue/watchers.rb', line 12 def jira_key @jira_key end |
Class Method Details
.add(name, key) ⇒ Object
Adds a new Watcher to the Issue
- Arguments
-
:name (required) name of the watcher
:key (required) issue key
48 49 50 51 |
# File 'lib/jiralicious/issue/watchers.rb', line 48 def add(name, key) issueKey_test(key) fetch({:method => :post, :body => name, :body_override => true, :parent => parent_name, :parent_key => key}) end |
.find_by_key(key) ⇒ Object
Finds all watchers based on the provided Issue Key
- Arguments
-
:key (required) issue key to find
32 33 34 35 36 37 38 |
# File 'lib/jiralicious/issue/watchers.rb', line 32 def find_by_key(key) issueKey_test(key) response = fetch({:parent => parent_name, :parent_key => key}) a = new(response) a.jira_key = key return a end |
.remove(name, key) ⇒ Object
Removes/Deletes a Watcher from the Issue
- Arguments
-
:name (required) name of the watcher
:key (required) issue key
61 62 63 64 |
# File 'lib/jiralicious/issue/watchers.rb', line 61 def remove(name, key) issueKey_test(key) fetch({:method => :delete, :body_to_params => true, :body => {:username => name}, :parent => parent_name, :parent_key => key}) end |
Instance Method Details
#add(name) ⇒ Object
Adds a new Watcher to the Issue
- Arguments
-
:name (required) name of the watcher
80 81 82 |
# File 'lib/jiralicious/issue/watchers.rb', line 80 def add(name) self.class.add(name, @jira_key) end |
#find ⇒ Object
Finds all watchers based on the provided Issue Key
70 71 72 |
# File 'lib/jiralicious/issue/watchers.rb', line 70 def find self.class.find_by_key(@jira_key) end |
#remove(name) ⇒ Object
Removes/Deletes a Watcher from the Issue
87 88 89 |
# File 'lib/jiralicious/issue/watchers.rb', line 87 def remove(name) self.class.remove(name, @jira_key) end |