class JIRA::Resource::Issue
Because of circular dependency Issue->IssueLink->Issue we have to declare JIRA::Resource::Issue class.
Public Class Methods
all(client)
click to toggle source
# File lib/jira/resource/issue.rb, line 45 def self.all(client) start_at = 0 max_results = 1000 result = [] loop do url = client.options[:rest_base_path] + "/search?expand=transitions.fields&maxResults=#{max_results}&startAt=#{start_at}" response = client.get(url) json = parse_json(response.body) json['issues'].map do |issue| result.push(client.Issue.build(issue)) end break if json['issues'].size == 0 start_at += json['issues'].size end result end
jql(client, jql, options = {fields: nil, start_at: nil, max_results: nil, expand: nil, validate_query: true})
click to toggle source
# File lib/jira/resource/issue.rb, line 63 def self.jql(client, jql, options = {fields: nil, start_at: nil, max_results: nil, expand: nil, validate_query: true}) url = client.options[:rest_base_path] + "/search?jql=#{CGI.escape(jql)}" url << "&fields=#{options[:fields].map{ |value| CGI.escape(client.Field.name_to_id(value)) }.join(',')}" if options[:fields] url << "&startAt=#{CGI.escape(options[:start_at].to_s)}" if options[:start_at] url << "&maxResults=#{CGI.escape(options[:max_results].to_s)}" if options[:max_results] url << "&validateQuery=false" if options[:validate_query] === false if options[:expand] options[:expand] = [options[:expand]] if options[:expand].is_a?(String) url << "&expand=#{options[:expand].to_a.map{ |value| CGI.escape(value.to_s) }.join(',')}" end response = client.get(url) json = parse_json(response.body) if options[:max_results] and options[:max_results] == 0 return json['total'] end json['issues'].map do |issue| client.Issue.build(issue) end end
Public Instance Methods
editmeta()
click to toggle source
# File lib/jira/resource/issue.rb, line 103 def editmeta editmeta_url = client.options[:rest_base_path] + "/#{self.class.endpoint_name}/#{key}/editmeta" response = client.get(editmeta_url) json = self.class.parse_json(response.body) json['fields'] end
fetch(reload = false, query_params = {})
click to toggle source
Fetches the attributes for the specified resource from JIRA unless the resource is already expanded and the optional force reload flag is not set
# File lib/jira/resource/issue.rb, line 89 def fetch(reload = false, query_params = {}) return if expanded? && !reload response = client.get(url_with_query_params(url, query_params)) set_attrs_from_response(response) if @attrs and @attrs['fields'] and @attrs['fields']['worklog'] and @attrs['fields']['worklog']['total'] > @attrs['fields']['worklog']['maxResults'] worklog_url = client.options[:rest_base_path] + "/#{self.class.endpoint_name}/#{id}/worklog" response = client.get(worklog_url) unless response.body.nil? or response.body.length < 2 set_attrs({'fields' => { 'worklog' => self.class.parse_json(response.body) }}, false) end end @expanded = true end
method_missing(method_name, *args, &block)
click to toggle source
Calls superclass method
JIRA::Base#method_missing
# File lib/jira/resource/issue.rb, line 119 def method_missing(method_name, *args, &block) if attrs.keys.include?('fields') if attrs['fields'].keys.include?(method_name.to_s) attrs['fields'][method_name.to_s] else official_name=client.Field.name_to_id(method_name) if attrs['fields'].keys.include?(official_name) attrs['fields'][official_name] else super(method_name, *args, &block) end end else super(method_name, *args, &block) end end
respond_to?(method_name, include_all=false)
click to toggle source
Calls superclass method
JIRA::Base#respond_to?
# File lib/jira/resource/issue.rb, line 111 def respond_to?(method_name, include_all=false) if attrs.keys.include?('fields') && [method_name.to_s, client.Field.name_to_id(method_name)].any? {|k| attrs['fields'].key?(k)} true else super(method_name) end end