Module: SmartCore::Validator::ErrorsController

Extended by:
ErrorsController
Included in:
ErrorsController
Defined in:
lib/smart_core/validator/errors_controller.rb,
lib/smart_core/validator/errors_controller/error_per_attribute.rb,
lib/smart_core/validator/errors_controller/many_errors_per_attribute.rb

Defined Under Namespace

Classes: Base, ErrorPerAttribute, ManyErrorsPerAttribute

Constant Summary collapse

ALLOWED_MANAGING_TYPES =
{
  error_per_attribute: 'ErrorPerAttribute',
  many_errors_per_attribute: 'ManyErrorsPerAttribute'
}.freeze

Instance Method Summary collapse

Instance Method Details

#resolve_from(managing_type) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/smart_core/validator/errors_controller.rb', line 15

def resolve_from(managing_type)
  unless ALLOWED_MANAGING_TYPES.key?(managing_type)
    raise ArgumentError, "invalid handling type. allowed is: #{ALLOWED_MANAGING_TYPES.keys}"
  end

  name = ALLOWED_MANAGING_TYPES[managing_type]
  ::SmartCore::Validator::ErrorsController.const_get(name).new
end