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

Methods included from ClassHelpers

#class_resolver, #descendants, #descendants?, #inheritable_attrs, #inheritable_class_vars, #inherited, #instance_variable_name, #new_class, #resolve_class, #to_constant

Methods included from Language::Methods::DelegateMissing

#delegate_missing_to, #method_missing, #respond_to_missing?

Class Attribute Details

.errorObject

Returns the value of attribute error.



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

def error
  @error
end

Class Method Details

.active_enviro_descObject



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

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



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

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

.error?Boolean

Returns:

  • (Boolean)


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

def error?
  !!error
end

.error_messageObject



92
93
94
# File 'lib/eco/api/common/loaders/config/workflow/mailer.rb', line 92

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

.errors_n_warnings(io) ⇒ Object



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

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

.log_err_n_warn(io) ⇒ Object



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

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)


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

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

.org_nameObject



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

def org_name
  self::ORG
end

.other_case?(io) ⇒ Boolean

Returns:

  • (Boolean)


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

def other_case?(io)
  cli.config.usecases.active(io: io).any? do |usecase, _data|
    %i[other].any? { |type| usecase.type == type }
  end
end

.some_update?(io) ⇒ Boolean

Returns:

  • (Boolean)


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

def some_update?(io)
  cli.config.usecases.active(io: io).any? do |usecase, _data|
    %i[transform sync].any? { |type| usecase.type == type }
  end
end

.trace_countObject



96
97
98
# File 'lib/eco/api/common/loaders/config/workflow/mailer.rb', line 96

def trace_count
  self::TRACE_COUNT
end