Class: Operations::Form::Builder

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

Overview

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

See Also:

Constant Summary collapse

NESTED_ATTRIBUTES_SUFFIX =
%r{_attributes\z}.freeze

Instance Method Summary collapse

Instance Method Details

#build(key_map:, model_map:, namespace: nil, class_name: nil, model_name: nil, persisted: nil) ⇒ Object



14
15
16
17
18
# File 'lib/operations/form/builder.rb', line 14

def build(key_map:, model_map:, namespace: nil, class_name: nil, model_name: nil, persisted: nil)
  return namespace.const_get(class_name) if namespace && class_name && namespace.const_defined?(class_name)

  traverse(key_map, model_map, namespace, class_name, model_name, [], persisted: persisted)
end