Class: Operations::Form::DeprecatedLegacyModelMapImplementation

Inherits:
Object
  • Object
show all
Extended by:
Dry::Initializer
Defined in:
lib/operations/form/deprecated_legacy_model_map_implementation.rb

Overview

Traverses the passed Dry::Schema::KeyMap and generates Base classes on the fly. Handles nested structures.

This class will be removed along with Operations::Command#form_model_map option removal along with the rest of form-related stuff.

Don’t use this class in you code, instead, copy it and modify to you liking.

See Also:

Constant Summary collapse

TYPE =
Operations::Types::Hash.map(
  Operations::Types::Coercible::Array.of(
    Operations::Types::String | Operations::Types::Symbol | Operations::Types.Instance(Regexp)
  ),
  Operations::Types::String
)

Instance Method Summary collapse

Instance Method Details

#call(path) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/operations/form/deprecated_legacy_model_map_implementation.rb', line 24

def call(path)
  model_map_hash.find do |pathspec, _model|
    path.size == pathspec.size && path.zip(pathspec).all? do |slug, pattern|
      pattern.is_a?(Regexp) ? pattern.match?(slug) : slug == pattern
    end
  end&.second
end