Module: Methodical::Executable
- Included in:
- ActionItem, Modifier
- Defined in:
- lib/methodical/executable.rb
Instance Attribute Summary collapse
-
#raise_on_error ⇒ Object
writeonly
Sets the attribute raise_on_error.
Instance Method Summary collapse
- #catch_disposition ⇒ Object
-
#execute!(baton = nil, raise_on_error = raise_on_error?) ) ⇒ Object
Default exception handling: * RuntimeErrors are considered failures.
- #raise_on_error? ⇒ Boolean
Instance Attribute Details
#raise_on_error=(value) ⇒ Object (writeonly)
Sets the attribute raise_on_error
3 4 5 |
# File 'lib/methodical/executable.rb', line 3 def raise_on_error=(value) @raise_on_error = value end |
Instance Method Details
#catch_disposition ⇒ Object
38 39 40 41 42 43 |
# File 'lib/methodical/executable.rb', line 38 def catch_disposition result = catch(:methodical_disposition) do yield end Methodical::Disposition(result) end |
#execute!(baton = nil, raise_on_error = raise_on_error?) ) ⇒ Object
Default exception handling:
-
RuntimeErrors are considered failures. The exception will be captured and not re-raised.
-
StandardErrors are considered indicative of a programming error in the action. The action will be marked as bad and failure recorded; but the exception will not be re-thrown.
-
Exceptions not caught by the other cases are considered fatal errors. The step will be marked bad and the error recorded, and the exception will then be re-raised.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/methodical/executable.rb', line 14 def execute!(baton=nil, raise_on_error=raise_on_error?) disposition = catch_disposition do call(baton, self) end rescue RuntimeError => error disposition = save_and_return_disposition(:failed, error., nil, error) raise if raise_on_error disposition rescue StandardError => error disposition = save_and_return_disposition(:bad, error., nil, error) raise if raise_on_error disposition rescue Exception => error save_and_return_disposition(:bad, error., nil, error) raise else save_and_return_disposition( disposition.status, disposition.explanation, disposition.result, nil, disposition.details) end |
#raise_on_error? ⇒ Boolean
45 46 47 |
# File 'lib/methodical/executable.rb', line 45 def raise_on_error? defined?(@raise_on_error) ? @raise_on_error : false end |