Class: Blacklight::Configuration::SortField
- Inherits:
-
Field
- Object
- OpenStruct
- OpenStructWithHashAccess
- Field
- Blacklight::Configuration::SortField
- Defined in:
- lib/blacklight/configuration/sort_field.rb
Instance Attribute Summary collapse
-
#sort ⇒ String
The sort specification to use; defaults to the value of field (which is used in the user-facing parameters).
Attributes inherited from Field
#field, #if, #key, #label, #unless
Instance Method Summary collapse
Methods inherited from Field
#default_label, #display_label
Methods inherited from OpenStructWithHashAccess
#deep_dup, #deep_transform_values, #merge, #merge!, #reverse_merge, #select, #sort_by, #sort_by!, #to_h, #try
Instance Attribute Details
#sort ⇒ String
Returns the sort specification to use; defaults to the value of field (which is used in the user-facing parameters).
8 9 10 11 12 13 14 15 16 |
# File 'lib/blacklight/configuration/sort_field.rb', line 8 def normalize! blacklight_config = nil super self.field ||= label&.parameterize self.field ||= sort self.sort ||= self.field self end |
Instance Method Details
#normalize!(blacklight_config = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/blacklight/configuration/sort_field.rb', line 8 def normalize! blacklight_config = nil super self.field ||= label&.parameterize self.field ||= sort self.sort ||= self.field self end |
#validate! ⇒ Object
18 19 20 |
# File 'lib/blacklight/configuration/sort_field.rb', line 18 def validate! raise ArgumentError.new, "Must supply a sort string" if self.sort.nil? end |