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.
22 23 24 25 26 27 28 |
# File 'lib/dry/schema/step.rb', line 22 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.
16 17 18 |
# File 'lib/dry/schema/step.rb', line 16 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.
10 11 12 |
# File 'lib/dry/schema/step.rb', line 10 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.
19 20 21 |
# File 'lib/dry/schema/step.rb', line 19 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.
13 14 15 |
# File 'lib/dry/schema/step.rb', line 13 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.
31 32 33 34 35 36 37 |
# File 'lib/dry/schema/step.rb', line 31 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.
40 41 42 43 44 45 46 47 |
# File 'lib/dry/schema/step.rb', line 40 def scoped(parent_path) self.class.new( type: type, name: name, executor: executor, path: Path.new([*parent_path, *path]) ) end |