Class: TxghQueue::Supervisor
- Inherits:
-
Object
- Object
- TxghQueue::Supervisor
- Defined in:
- lib/txgh-queue/supervisor.rb
Constant Summary collapse
- ERROR_HANDLERS =
ErrorHandlers::StandardErrors should always come last as a catch-all for unexpected errors. All errors handled by this supervisor inherit from StandardError, so putting it too early in the handler list may cause an error to be mis-handled.
[ ErrorHandlers::ServerResponse, ErrorHandlers::Github, ErrorHandlers::Transifex, ErrorHandlers::TxghErrors, ErrorHandlers::StandardErrors ]
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
Class Method Summary collapse
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(&block) ⇒ Supervisor
constructor
A new instance of Supervisor.
Constructor Details
#initialize(&block) ⇒ Supervisor
Returns a new instance of Supervisor.
27 28 29 |
# File 'lib/txgh-queue/supervisor.rb', line 27 def initialize(&block) @block = block end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
25 26 27 |
# File 'lib/txgh-queue/supervisor.rb', line 25 def block @block end |
Class Method Details
.supervise(&block) ⇒ Object
20 21 22 |
# File 'lib/txgh-queue/supervisor.rb', line 20 def supervise(&block) new(&block).execute end |
Instance Method Details
#execute ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/txgh-queue/supervisor.rb', line 31 def execute response = block.call rescue StandardError => e status = status_for_error(e) Result.new(status, e) else status = status_for_response(response) Result.new(status, response) end |