Class: Dry::Operation::ClassContext::PrependManager Private
- Inherits:
-
Object
- Object
- Dry::Operation::ClassContext::PrependManager
- Defined in:
- lib/dry/operation/class_context/prepend_manager.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.
Instance Method Summary collapse
- #call(method:) ⇒ Object private
- #for_subclass(subclass) ⇒ Object private
-
#initialize(klass:, methods_to_prepend:, prepended_methods: []) ⇒ PrependManager
constructor
private
A new instance of PrependManager.
- #register(*methods) ⇒ Object private
- #void ⇒ Object private
Constructor Details
#initialize(klass:, methods_to_prepend:, prepended_methods: []) ⇒ PrependManager
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 PrependManager.
10 11 12 13 14 |
# File 'lib/dry/operation/class_context/prepend_manager.rb', line 10 def initialize(klass:, methods_to_prepend:, prepended_methods: []) @klass = klass @methods_to_prepend = methods_to_prepend @prepended_methods = prepended_methods end |
Instance Method Details
#call(method:) ⇒ 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.
33 34 35 36 37 38 |
# File 'lib/dry/operation/class_context/prepend_manager.rb', line 33 def call(method:) return self unless @methods_to_prepend.include?(method) @klass.include(StepsMethodPrepender.new(method: method)) @prepended_methods += [method] end |
#for_subclass(subclass) ⇒ 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.
40 41 42 43 44 45 46 |
# File 'lib/dry/operation/class_context/prepend_manager.rb', line 40 def for_subclass(subclass) self.class.new( klass: subclass, methods_to_prepend: @methods_to_prepend.dup, prepended_methods: [] ) end |
#register(*methods) ⇒ 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.
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/dry/operation/class_context/prepend_manager.rb', line 16 def register(*methods) ensure_pristine already_defined_methods = methods & @klass.instance_methods(false) if already_defined_methods.any? raise MethodsToPrependAlreadyDefinedError.new(methods: already_defined_methods) else @methods_to_prepend = methods end end |
#void ⇒ 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.
27 28 29 30 31 |
# File 'lib/dry/operation/class_context/prepend_manager.rb', line 27 def void ensure_pristine @methods_to_prepend = [] end |