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, #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
47 48 49 |
# File 'lib/jiralicious/issue/watchers.rb', line 47 def add(name, 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 |
# File 'lib/jiralicious/issue/watchers.rb', line 32 def find_by_key(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
59 60 61 |
# File 'lib/jiralicious/issue/watchers.rb', line 59 def remove(name, 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
77 78 79 |
# File 'lib/jiralicious/issue/watchers.rb', line 77 def add(name) self.class.add(name, @jira_key) end |
#find ⇒ Object
Finds all watchers based on the provided Issue Key
67 68 69 |
# File 'lib/jiralicious/issue/watchers.rb', line 67 def find self.class.find_by_key(@jira_key) end |
#remove(name) ⇒ Object
Removes/Deletes a Watcher from the Issue
84 85 86 |
# File 'lib/jiralicious/issue/watchers.rb', line 84 def remove(name) self.class.remove(name, @jira_key) end |