Class: RedmineRemotes::IssueFetch::Base

Inherits:
EacRailsUtils::Models::Tableless
  • Object
show all
Includes:
EacRailsUtils::Models::FetchErrors
Defined in:
app/tableless_models/redmine_remotes/issue_fetch/base.rb,
app/tableless_models/redmine_remotes/issue_fetch/base/local_issue.rb,
app/tableless_models/redmine_remotes/issue_fetch/base/remote_issue.rb,
app/tableless_models/redmine_remotes/issue_fetch/base/provider_issue.rb

Direct Known Subclasses

Create, Update

Defined Under Namespace

Modules: LocalIssue, ProviderIssue, RemoteIssue

Instance Method Summary collapse

Instance Method Details

#author_presentObject



21
22
23
24
25
26
27
# File 'app/tableless_models/redmine_remotes/issue_fetch/base.rb', line 21

def author_present
  return if provider_issue.blank?
  return if local_issue_author.present?

  errors.add(:remote_code,
             "Usuário local não encontrado para \"#{provider_issue.}\"")
end

#provider_issue_presentObject



29
30
31
32
33
34
35
# File 'app/tableless_models/redmine_remotes/issue_fetch/base.rb', line 29

def provider_issue_present
  return if issue_remote_code.blank?
  return if provider_issue.present?

  errors.add(:remote_code,
             "Demanda remota não encontrada com o código \"#{issue_remote_code}\"")
end

#saveObject



37
38
39
40
41
42
43
44
# File 'app/tableless_models/redmine_remotes/issue_fetch/base.rb', line 37

def save
  ::Issue.transaction do
    return false unless valid? # rubocop:disable Rails/TransactionExitStatement
    return false unless save_local_issue # rubocop:disable Rails/TransactionExitStatement
    return false unless save_remote_issue # rubocop:disable Rails/TransactionExitStatement
  end
  true
end