Class: RedmineRest::Models::Issue

Inherits:
ActiveResource::Base show all
Defined in:
lib/redmine_rest/models/issue.rb,
lib/redmine_rest/models/issue/journal.rb,
lib/redmine_rest/models/issue/journal_detail.rb

Overview

issue model

Defined Under Namespace

Classes: Journal

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ActiveResource::Base

find_by_id

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



104
105
106
107
# File 'lib/redmine_rest/models/issue.rb', line 104

def method_missing(method, *args)
  return super if block_given? || method.to_s.end_with?('?') || !args.empty?
  attributes[method]
end

Class Method Details

.find(what, options = {}) ⇒ Object

Adds journals, relations, children and watchers to request.

Be careful, even if issue has watchers, it won’t be loaded, because REST API can load them only after v2.3.0 (see Redmine docs)



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/redmine_rest/models/issue.rb', line 45

def self.find(what, options = {})
  options[:params] = {} unless options[:params]
  params = options[:params]

  if params[:include]
    params[:include] += ',journals,relations,children,watchers,attachments'
  else # doubling is not bad
    params[:include] = 'journals,relations,children,watchers,attachments'
  end

  super(what, options)
end

Instance Method Details

#assigned_to=(user) ⇒ Object

Sets #assigned_to_id via User object



91
92
93
94
# File 'lib/redmine_rest/models/issue.rb', line 91

def assigned_to=(user)
  fail ArgumentError unless user.is_a? User
  self.assigned_to_id = user.id
end

#fixed_version=(version) ⇒ Object Also known as: version=

Sets #fixed_version_id via Version object.



65
66
67
68
# File 'lib/redmine_rest/models/issue.rb', line 65

def fixed_version=(version)
  fail ArgumentError unless version.is_a? Version
  self.fixed_version_id = version.id
end

#parent=(issue) ⇒ Object

Sets #parent_issue_id via Issue object



99
100
101
102
# File 'lib/redmine_rest/models/issue.rb', line 99

def parent=(issue)
  fail ArgumentError unless issue.is_a? Issue
  self.parent_issue_id = issue.id
end

#project=(project) ⇒ Object

Sets #project_id via Project object.



83
84
85
86
# File 'lib/redmine_rest/models/issue.rb', line 83

def project=(project)
  fail ArgumentError unless project.is_a? Project
  self.project_id = project.id
end

#tracker=(tracker) ⇒ Object

Sets #tracker_id via Tracker object.



75
76
77
78
# File 'lib/redmine_rest/models/issue.rb', line 75

def tracker=(tracker)
  fail ArgumentError unless tracker.is_a? Tracker
  self.tracker_id = tracker.id
end

#tracker_idObject



35
36
37
# File 'lib/redmine_rest/models/issue.rb', line 35

def tracker_id
  attributes[:tracker_id] || tracker? && tracker.id
end

#versionObject



58
59
60
# File 'lib/redmine_rest/models/issue.rb', line 58

def version
  fixed_version
end