Class: JIRA::Resource::Watcher

Inherits:
Base
  • Object
show all
Defined in:
lib/jira/resource/watcher.rb

Constant Summary

Constants inherited from Base

Base::QUERY_PARAMS_FOR_SEARCH, Base::QUERY_PARAMS_FOR_SINGLE_FETCH

Instance Attribute Summary

Attributes inherited from Base

#attrs, #client, #deleted, #expanded

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

belongs_to, belongs_to_relationships, build, collection_attributes_are_nested, collection_path, #collection_path, #delete, #fetch, find, #has_errors?, has_many, has_one, #id, #initialize, key_attribute, #key_value, #method_missing, nested_collections, #new_record?, parse_json, #patched_url, #path_component, #respond_to?, #save, #set_attrs, #set_attrs_from_response, singular_path, #to_json, #to_s, #to_sym, #url

Constructor Details

This class inherits a constructor from JIRA::Base

Dynamic Method Handling

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

Class Method Details

.all(client, options = {}) ⇒ Object

Raises:

  • (ArgumentError)

15
16
17
18
19
20
21
22
23
24
25
# File 'lib/jira/resource/watcher.rb', line 15

def self.all(client, options = {})
  issue = options[:issue]
  raise ArgumentError, 'parent issue is required' unless issue

  path = "#{issue.self}/#{endpoint_name}"
  response = client.get(path)
  json = parse_json(response.body)
  json['watchers'].map do |watcher|
    issue.watchers.build(watcher)
  end
end

.endpoint_nameObject


11
12
13
# File 'lib/jira/resource/watcher.rb', line 11

def self.endpoint_name
  'watchers'
end

Instance Method Details

#save!(user_id, path = nil) ⇒ Object


27
28
29
30
31
# File 'lib/jira/resource/watcher.rb', line 27

def save!(user_id, path = nil)
  path ||= new_record? ? url : patched_url
  response = client.post(path, user_id.to_json)
  true
end