class Dry::Schema::Step
@api private
Attributes
executor[R]
@api private
name[R]
@api private
path[R]
@api private
type[R]
@api private
Public Class Methods
new(type:, name:, executor:, path: Path::EMPTY)
click to toggle source
@api private
# 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
Public Instance Methods
call(result)
click to toggle source
@api private
# 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)
click to toggle source
@api private
# 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
Private Instance Methods
validate_name(name)
click to toggle source
@api private
# File lib/dry/schema/step.rb, line 53 def validate_name(name) return if STEPS_IN_ORDER.include?(name) raise ArgumentError, "Undefined step name #{name}. Available names: #{STEPS_IN_ORDER}" end