Class: Cloudflare::Email::TaskBase
- Inherits:
-
Object
- Object
- Cloudflare::Email::TaskBase
- Defined in:
- lib/cloudflare/email/task_base.rb
Overview
Shared scaffolding for ‘bin/rails cloudflare:email:*` tasks.
Each task subclass implements ‘#run` (which raises on missing input or returns nil/0 on success). The base class wraps that with consistent credential exposure, error formatting, and exit codes so every task feels the same to the user.
Subclasses use ‘credential(:name)` or the shorthand readers (`account_id`, `api_token`, `management_token`, `ingress_secret`) to pull config. Raising any exception from `#run` is converted to a non-zero exit with a uniformly-formatted error message.
Direct Known Subclasses
DeployWorkerTask, ProvisionCatchallTask, ProvisionRouteTask, SendTest
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(io: $stdout, **opts) ⇒ TaskBase
constructor
A new instance of TaskBase.
Constructor Details
#initialize(io: $stdout, **opts) ⇒ TaskBase
Returns a new instance of TaskBase.
21 22 23 24 |
# File 'lib/cloudflare/email/task_base.rb', line 21 def initialize(io: $stdout, **opts) @io = io @opts = opts end |
Class Method Details
.call(**kwargs) ⇒ Object
17 18 19 |
# File 'lib/cloudflare/email/task_base.rb', line 17 def self.call(**kwargs) new(**kwargs).call end |
Instance Method Details
#call ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/cloudflare/email/task_base.rb', line 26 def call run 0 rescue Cloudflare::Email::Error => e @io.puts " ERROR: #{e.}" @io.puts " Status: #{e.status}" if e.status 1 rescue => e @io.puts " ERROR: #{e.}" 1 end |