Class: Hyrax::FlexibleSchemaValidators::RedirectsValidator Private

Inherits:
Object
  • Object
show all
Defined in:
app/services/hyrax/flexible_schema_validators/redirects_validator.rb

Overview

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.

Validates the redirects property in an m3 profile against the two-layer feature gating (config + Flipflop):

config flipflop property result
off n/a present warn (property will be ignored)
off n/a absent silent
on off present warn (property is loaded but unused)
on off absent silent
on on absent error (property is required)
on on present check available_on.class lists at
least one work or collection class
declared in this profile's classes

Instance Method Summary collapse

Constructor Details

#initialize(profile:, errors:, warnings: []) ⇒ RedirectsValidator

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 RedirectsValidator.

Parameters:

  • profile (Hash)

    the flexible metadata profile

  • errors (Array<String>)

    an array to append errors to

  • warnings (Array<String>) (defaults to: [])

    an array to append warnings to



26
27
28
29
30
# File 'app/services/hyrax/flexible_schema_validators/redirects_validator.rb', line 26

def initialize(profile:, errors:, warnings: [])
  @profile = profile
  @errors = errors
  @warnings = warnings
end

Instance Method Details

#validate!void

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.

This method returns an undefined value.

Validate the profile against the redirects requirements and append any human-readable error messages to #errors (or warnings to #warnings for the dead-property cases).



37
38
39
40
41
42
# File 'app/services/hyrax/flexible_schema_validators/redirects_validator.rb', line 37

def validate!
  return validate_when_config_off unless Hyrax.config.redirects_enabled?
  return validate_when_flipflop_off unless Flipflop.redirects?

  validate_when_enabled
end