Class: ServiceOperator::Context
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- ServiceOperator::Context
- Defined in:
- lib/service_operator/context.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#fail ⇒ Object
Public: Fail the ServiceOperator::Context.
- #failure? ⇒ Boolean
- #success? ⇒ Boolean
-
#validate(required_params: []) ⇒ Object
Public: Validate the ServiceOperator::Context.
Class Method Details
.build(args = {}) ⇒ Object
10 11 12 13 14 |
# File 'lib/service_operator/context.rb', line 10 def self.build(args={}) context = new(args) context.failure = false context end |
Instance Method Details
#fail ⇒ Object
Public: Fail the ServiceOperator::Context. Failing a context raises an error that rollback all changes at transaction steps. The context is also flagged as having failed.
25 26 27 28 |
# File 'lib/service_operator/context.rb', line 25 def fail self.failure = true raise Failure end |
#failure? ⇒ Boolean
34 35 36 |
# File 'lib/service_operator/context.rb', line 34 def failure? failure end |
#success? ⇒ Boolean
30 31 32 |
# File 'lib/service_operator/context.rb', line 30 def success? !failure end |
#validate(required_params: []) ⇒ Object
Public: Validate the ServiceOperator::Context. If any required param is missed in context then it fails context
18 19 20 |
# File 'lib/service_operator/context.rb', line 18 def validate(required_params: []) fail if required_params.any?(&:nil?) end |