Class: Dry::Operation::ClassContext::StepsMethodPrepender Private
- Inherits:
-
Module
- Object
- Module
- Dry::Operation::ClassContext::StepsMethodPrepender
- Defined in:
- lib/dry/operation/class_context/steps_method_prepender.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- FAILURE_HOOK_METHOD_NAME =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
:on_failure
- RESULT_HANDLER =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
lambda do |instance, method, result| return if result.success? || !(instance.methods + instance.private_methods).include?( FAILURE_HOOK_METHOD_NAME ) failure_hook = instance.method(FAILURE_HOOK_METHOD_NAME) case failure_hook.arity when 1 failure_hook.(result.failure) when 2 failure_hook.(result.failure, method) else raise FailureHookArityError.new(hook: failure_hook) end end
Instance Method Summary collapse
- #included(klass) ⇒ Object private
-
#initialize(method:, result_handler: RESULT_HANDLER) ⇒ StepsMethodPrepender
constructor
private
A new instance of StepsMethodPrepender.
Constructor Details
#initialize(method:, result_handler: RESULT_HANDLER) ⇒ StepsMethodPrepender
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of StepsMethodPrepender.
29 30 31 32 33 |
# File 'lib/dry/operation/class_context/steps_method_prepender.rb', line 29 def initialize(method:, result_handler: RESULT_HANDLER) super() @method = method @result_handler = result_handler end |
Instance Method Details
#included(klass) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
35 36 37 |
# File 'lib/dry/operation/class_context/steps_method_prepender.rb', line 35 def included(klass) klass.prepend(mod) end |