Class: Jiralicious::Component

Inherits:
Field
  • Object
show all
Defined in:
lib/jiralicious/component.rb

Instance Attribute Summary

Attributes inherited from Base

#loaded

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Field

#initialize

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

#parse!

Constructor Details

This class inherits a constructor from Jiralicious::Field

Dynamic Method Handling

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

Class Method Details

.create(details) ⇒ Object

Creates a new component

Arguments

:details (required) Component details to be created



16
17
18
19
# File 'lib/jiralicious/component.rb', line 16

def create(details)
  response = fetch({:method => :post, :body => details})
  new(response.parsed_response)
end

Returns the number of Issues associated with the Component

Arguments

:id (required) Component to count



27
28
29
30
31
# File 'lib/jiralicious/component.rb', line 27

def related_issue_counts(id)
  response = fetch({:key => "#{id}/relatedIssueCounts"})
  response.parsed_response['id'] = id
  Field.new(response.parsed_response)
end

.remove(remove_id, target_id = nil) ⇒ Object

Removes/Deletes a Component

Arguments

:remove_id (required) Component to remove/delete

:target_id (optional) Component to move issues to



41
42
43
44
45
46
47
# File 'lib/jiralicious/component.rb', line 41

def remove(remove_id, target_id = nil)
  body = {}
  if !target_id.nil?
    body.merge!("movIssuesTo"=>target_id)
  end
  fetch({:method => :delete, :key => remove_id, :body_to_params => true, :body => body}).parsed_response
end

.update(id, details) ⇒ Object

Updates a component

Arguments

:id (required) Component to be updated

:details (required) Details of the component to be updated



57
58
59
60
# File 'lib/jiralicious/component.rb', line 57

def update(id, details)
  response = fetch({:method => :put, :key => id, :body => details})
  new(response.parsed_response)
end

Instance Method Details

#component_keyObject

Holds the Component Key



7
# File 'lib/jiralicious/component.rb', line 7

property :component_key, :from => :id

#findObject

Finds all watchers based on the provided Issue Key



66
67
68
# File 'lib/jiralicious/component.rb', line 66

def find
  self.class.find_by_id(self.component_key)
end

Returns the number of Issues associated with the Component

Arguments

:id (required) Component to count



76
77
78
# File 'lib/jiralicious/component.rb', line 76

def related_issue_counts
  self.class.related_issue_counts(self.component_key).issueCount
end

#remove(target = nil) ⇒ Object

Removes/Deletes a Component

Arguments

:target_id (optional) Component to move issues to



86
87
88
# File 'lib/jiralicious/component.rb', line 86

def remove(target = nil)
  self.class.remove(self.component_key, target)
end

#update(details) ⇒ Object

Updates a component

Arguments

:details (required) Details of the component to be updated



96
97
98
99
100
101
# File 'lib/jiralicious/component.rb', line 96

def update(details)
  details.each do |k, v|
    self.send("#{k.to_s}=", v)
  end
  self.class.update(self.component_key, details)
end