Class: Jiralicious::Issue::Transitions
- Defined in:
- lib/jiralicious/issue/transitions.rb
Overview
The Transitions Class provides all of the functionality to retrieve, and use a transition associated with an Issue.
Instance Attribute Summary collapse
-
#meta ⇒ Object
Retrieves the meta data for the Transition based on the options, Issue Key and Transition ID provided.
Attributes inherited from Base
Class Method Summary collapse
-
.find(key) ⇒ Object
(also: find_all)
Retrieves the associated Transitions based on the Issue Key.
-
.find_by_key_and_id(key, id) ⇒ Object
Retrieves the Transition based on the Issue Key and Transition ID.
-
.go(key, id, options = {}) ⇒ Object
Processes the Transition based on the provided options.
-
.meta(key, id, options = {}) ⇒ Object
Retrieves the meta data for the Transition based on the options, Issue Key and Transition ID provided.
Instance Method Summary collapse
-
#all ⇒ Object
Retrieves the associated Transitions based on the Issue Key.
-
#go(options = {}) ⇒ Object
Processes the Transition based on the provided options.
-
#initialize(decoded_json = nil, default = nil) ⇒ Transitions
constructor
Initialization Method.
Methods inherited from Base
#endpoint_name, endpoint_name, fetch, 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, default = nil) ⇒ Transitions
Initialization Method
- Arguments
-
:decoded_json (optional) rubyized json object
:default (optional) default issue key
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/jiralicious/issue/transitions.rb', line 22 def initialize(decoded_json = nil, default = nil) @loaded = false @meta = nil if decoded_json.is_a? Array if decoded_json.length == 1 decoded_json = decoded_json[0] end end unless decoded_json.nil? if decoded_json.is_a? String self.class.property :jira_key self.jira_key = decoded_json elsif decoded_json.is_a? Hash properties_from_hash(decoded_json) super(decoded_json) parse!(decoded_json) @loaded = true else self.class.property :jira_key self.jira_key = default decoded_json.each do |list| self.class.property :"id_#{list['id']}" self.merge!({"id_#{list['id']}" => self.class.new(list)}) end end end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Jiralicious::Base
Instance Attribute Details
#meta ⇒ Object
Retrieves the meta data for the Transition based on the options, Issue Key and Transition ID provided.
12 13 14 |
# File 'lib/jiralicious/issue/transitions.rb', line 12 def @meta end |
Class Method Details
.find(key) ⇒ Object Also known as: find_all
Retrieves the associated Transitions based on the Issue Key
- Arguments
-
:key (required) issue key
57 58 59 60 61 62 63 64 |
# File 'lib/jiralicious/issue/transitions.rb', line 57 def find(key) issueKey_test(key) response = fetch({:parent => parent_name, :parent_key => key}) response.parsed_response['transitions'].each do |t| t['jira_key'] = key end return new(response.parsed_response['transitions'], key) end |
.find_by_key_and_id(key, id) ⇒ Object
Retrieves the Transition based on the Issue Key and Transition ID
- Arguments
-
:key (required) issue key
:id (required) transition id
74 75 76 77 78 79 80 81 |
# File 'lib/jiralicious/issue/transitions.rb', line 74 def find_by_key_and_id(key, id) issueKey_test(key) response = fetch({:parent => parent_name, :parent_key => key, :body => {"transitionId" => id}, :body_to_params => true }) response.parsed_response['transitions'].each do |t| t['jira_key'] = key end return new(response.parsed_response['transitions']) end |
.go(key, id, options = {}) ⇒ Object
Processes the Transition based on the provided options
- Arguments
-
:key (required) issue key
:id (required) transaction id
:comment (optional) comment to be added with transition
:fields (mixed) the fields that are required or optional
based on the individual transition
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/jiralicious/issue/transitions.rb', line 96 def go(key, id, = {}) issueKey_test(key) transition = {"transition" => {"id" => id}} if [:comment].is_a? String transition.merge!({"update" => {"comment" => [{"add" => {"body" => [:comment].to_s}}]}}) elsif [:comment].is_a? Jiralicious::Issue::Fields transition.merge!([:comment].format_for_update) elsif [:comment].is_a? Hash transition.merge!({"update" => [:comment]}) end if [:fields].is_a? Jiralicious::Issue::Fields transition.merge!([:fields].format_for_create) elsif [:fields].is_a? Hash transition.merge!({"fields" => [:fields]}) end fetch({:method => :post, :parent => parent_name, :parent_key => key, :body => transition}) end |
.meta(key, id, options = {}) ⇒ Object
Retrieves the meta data for the Transition based on the options, Issue Key and Transition ID provided.
- Arguments
-
:key (required) issue key
:id (required) transaction id
:return (optional) boolean flag to determine if an object or hash is returned
125 126 127 128 129 130 131 132 133 |
# File 'lib/jiralicious/issue/transitions.rb', line 125 def (key, id, = {}) issueKey_test(key) response = fetch({:method => :get, :parent => parent_name, :parent_key => key, :body_to_params => true, :body => {"transitionId" => id, "expand" => "transitions.fields"}}) response.parsed_response['transitions'].each do |t| t['jira_key'] = key end return ([:return].nil?) ? new(response.parsed_response['transitions'], key) : response end |
Instance Method Details
#all ⇒ Object
Retrieves the associated Transitions based on the Issue Key
141 142 143 |
# File 'lib/jiralicious/issue/transitions.rb', line 141 def all self.class.all(self.jira_key) if self.jira_key end |
#go(options = {}) ⇒ Object
Processes the Transition based on the provided options
- Arguments
-
:options are passed on to the ‘class.go’ function
151 152 153 |
# File 'lib/jiralicious/issue/transitions.rb', line 151 def go( = {}) self.class.go(self.jira_key, self.id, ) end |