Class: RedmineRemotes::IssueFetch::Create

Inherits:
Base
  • Object
show all
Defined in:
app/tableless_models/redmine_remotes/issue_fetch/create.rb,
app/tableless_models/redmine_remotes/issue_fetch/create/local_issue.rb,
app/tableless_models/redmine_remotes/issue_fetch/create/remote_issue.rb

Defined Under Namespace

Modules: LocalIssue, RemoteIssue

Instance Method Summary collapse

Methods inherited from Base

#author_present, #provider_issue_present

Instance Method Details

#default_error_columnObject



19
20
21
# File 'app/tableless_models/redmine_remotes/issue_fetch/create.rb', line 19

def default_error_column
  :issue_remote_code
end

#saveObject



23
24
25
# File 'app/tableless_models/redmine_remotes/issue_fetch/create.rb', line 23

def save
  remote_issue_by_remote_code.present? ? update : super
end

#tracker_in_projectObject



27
28
29
30
31
32
# File 'app/tableless_models/redmine_remotes/issue_fetch/create.rb', line 27

def tracker_in_project
  return unless local_tracker.present? && project.present?
  return if project.trackers.include?(local_tracker)

  errors.add(:local_tracker, 'is not a tracker of project')
end

#updateObject



34
35
36
37
38
39
40
41
# File 'app/tableless_models/redmine_remotes/issue_fetch/create.rb', line 34

def update
  update_record = ::RedmineRemotes::IssueFetch::Update
                    .new(remote_issue: remote_issue_by_remote_code)
  return true if update_record.save

  fetch_record_errors(update_record, default_column: default_error_column)
  false
end