Class: Hyrax::FlexibleSchemaValidators::SortPropertiesValidator
- Inherits:
-
Object
- Object
- Hyrax::FlexibleSchemaValidators::SortPropertiesValidator
- Defined in:
- app/services/hyrax/flexible_schema_validators/sort_properties_validator.rb
Instance Attribute Summary collapse
-
#profile ⇒ Object
readonly
Returns the value of attribute profile.
-
#sort_properties ⇒ Object
readonly
Returns the value of attribute sort_properties.
Instance Method Summary collapse
-
#initialize(profile, warnings) ⇒ SortPropertiesValidator
constructor
A new instance of SortPropertiesValidator.
- #validate! ⇒ Object
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
#profile ⇒ Object (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_properties ⇒ Object (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 |