Class: Dry::Schema::Step Private
- Inherits:
-
Object
- Object
- Dry::Schema::Step
- Defined in:
- lib/dry/schema/step.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 Attribute Summary collapse
- #executor ⇒ Object readonly private
- #name ⇒ Object readonly private
- #path ⇒ Object readonly private
- #type ⇒ Object readonly private
Instance Method Summary collapse
- #call(result) ⇒ Object private
-
#initialize(type:, name:, executor:, path: Path::EMPTY) ⇒ Step
constructor
private
A new instance of Step.
- #scoped(parent_path) ⇒ Object private
Constructor Details
#initialize(type:, name:, executor:, path: Path::EMPTY) ⇒ Step
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 Step.
23 24 25 26 27 28 29 |
# File 'lib/dry/schema/step.rb', line 23 def initialize(type:, name:, executor:, path: Path::EMPTY) @type = type @name = name @executor = executor @path = path validate_name(name) end |
Instance Attribute Details
#executor ⇒ Object (readonly)
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.
17 18 19 |
# File 'lib/dry/schema/step.rb', line 17 def executor @executor end |
#name ⇒ Object (readonly)
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.
11 12 13 |
# File 'lib/dry/schema/step.rb', line 11 def name @name end |
#path ⇒ Object (readonly)
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.
20 21 22 |
# File 'lib/dry/schema/step.rb', line 20 def path @path end |
#type ⇒ Object (readonly)
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.
14 15 16 |
# File 'lib/dry/schema/step.rb', line 14 def type @type end |
Instance Method Details
#call(result) ⇒ 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.
32 33 34 35 36 37 38 |
# File 'lib/dry/schema/step.rb', line 32 def call(result) scoped_result = path.equal?(Path::EMPTY) ? result : result.at(path) output = executor.(scoped_result) scoped_result.replace(output) if output.is_a?(Hash) output end |
#scoped(parent_path) ⇒ 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.
41 42 43 44 45 46 47 48 |
# File 'lib/dry/schema/step.rb', line 41 def scoped(parent_path) self.class.new( type: type, name: name, executor: executor, path: Path.new([*parent_path, *path]) ) end |