Class: Hyrax::FlexibleSchemaValidators::SortPropertiesValidator

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(profile, warnings) ⇒ SortPropertiesValidator

Returns a new instance of SortPropertiesValidator.



8
9
10
11
12
# File 'app/services/hyrax/flexible_schema_validators/sort_properties_validator.rb', line 8

def initialize(profile, warnings)
  @profile = profile
  @warnings = warnings
  @sort_properties = find_sort_properties
end

Instance Attribute Details

#profileObject (readonly)

Returns the value of attribute profile.



6
7
8
# File 'app/services/hyrax/flexible_schema_validators/sort_properties_validator.rb', line 6

def profile
  @profile
end

#sort_propertiesObject (readonly)

Returns the value of attribute sort_properties.



6
7
8
# File 'app/services/hyrax/flexible_schema_validators/sort_properties_validator.rb', line 6

def sort_properties
  @sort_properties
end

Instance Method Details

#validate!Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/services/hyrax/flexible_schema_validators/sort_properties_validator.rb', line 14

def validate!
  sort_properties.each do |property|
    properties_without_sort_properties = work_types_from_profile - (profile.dig('properties', property, 'available_on', 'class') || [])
    next if properties_without_sort_properties.empty?

    msg = I18n.t(
      'hyrax.flexible_schema_validators.sort_properties_validator.warnings.message',
      property: property,
      classes: properties_without_sort_properties.join(', ')
    )
    @warnings << msg
  end
end