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.



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

def error
  @error
end

Class Method Details

.base_subjectObject



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

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

.error?Boolean

Returns:

  • (Boolean)


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

def error?
  !!error
end

.error_messageObject



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

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

.errors_n_warnings(io) ⇒ Object



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

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

.log_err_n_warn(io) ⇒ Object



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

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

.org_nameObject



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

def org_name
  self::ORG
end

.other_case?(io) ⇒ Boolean

Returns:

  • (Boolean)


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

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)


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

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



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

def trace_count
  self::TRACE_COUNT
end