Class: Eco::API::Common::Loaders::Workflow::Mailer

Inherits:
Eco::API::Common::Loaders::Workflow show all
Defined in:
lib/eco/api/common/loaders/config/workflow/mailer.rb

Direct Known Subclasses

Eco::API::Custom::Mailer

Constant Summary collapse

ORG =
'your organization'.freeze
TRACE_COUNT =
3

Class Attribute Summary collapse

Class Method Summary collapse

Methods inherited from Eco::API::Common::Loaders::Workflow

workflow

Methods inherited from Config

active_enviro, cli, config, config_block

Class Attribute Details

.errorObject

Returns the value of attribute error.



37
38
39
# File 'lib/eco/api/common/loaders/config/workflow/mailer.rb', line 37

def error
  @error
end

Class Method Details

.active_enviro_descObject



47
48
49
50
51
52
53
# File 'lib/eco/api/common/loaders/config/workflow/mailer.rb', line 47

def active_enviro_desc
  space_desc = config.active_enviro_space.to_s.strip
  space_desc = ''                          if space_desc == 'default'
  space_desc = " - space: '#{space_desc}'" unless space_desc.empty?

  "#{active_enviro}#{space_desc}"
end

.base_subjectObject



43
44
45
# File 'lib/eco/api/common/loaders/config/workflow/mailer.rb', line 43

def base_subject
  "#{org_name} (#{active_enviro_desc}) at #{Time.now.iso8601}"
end

.error?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/eco/api/common/loaders/config/workflow/mailer.rb', line 55

def error?
  !!error
end

.error_messageObject



82
83
84
# File 'lib/eco/api/common/loaders/config/workflow/mailer.rb', line 82

def error_message
  error&.patch_full_message(trace_count: 3)
end

.errors_n_warnings(io) ⇒ Object



71
72
73
# File 'lib/eco/api/common/loaders/config/workflow/mailer.rb', line 71

def errors_n_warnings(io)
  [error_message, log_err_n_warn(io)].join("\n")
end

.general_messages(io) ⇒ Object



64
65
66
67
68
69
# File 'lib/eco/api/common/loaders/config/workflow/mailer.rb', line 64

def general_messages(io)
  gen_msg = io.logger.cache.logs(level: %i[general])
  return if gen_msg.empty?

  "GENERAL MESSAGES:\n#{gen_msg.join}\n"
end

.log_err_n_warn(io) ⇒ Object



75
76
77
78
79
80
# File 'lib/eco/api/common/loaders/config/workflow/mailer.rb', line 75

def log_err_n_warn(io)
  warn_errors = io.logger.cache.logs(level: %i[error warn])
  return if warn_errors.empty?

  "ALL WARNINGS & ERRORS:\n#{warn_errors.join}\n"
end

.maybe_error_pages_or_tree_updates?(io) ⇒ Boolean

Note:

at some stage, tree cases should have their own case type

Returns:

  • (Boolean)


60
61
62
# File 'lib/eco/api/common/loaders/config/workflow/mailer.rb', line 60

def maybe_error_pages_or_tree_updates?(io)
  some_other_case?(io) && error?
end

.org_nameObject



39
40
41
# File 'lib/eco/api/common/loaders/config/workflow/mailer.rb', line 39

def org_name
  self::ORG
end

.trace_countObject



86
87
88
# File 'lib/eco/api/common/loaders/config/workflow/mailer.rb', line 86

def trace_count
  self::TRACE_COUNT
end