Class: Blacklight::Configuration::SortField

Inherits:
Field show all
Defined in:
lib/blacklight/configuration/sort_field.rb

Instance Attribute Summary collapse

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

#sortString

Returns the sort specification to use; defaults to the value of field (which is used in the user-facing parameters).

Returns:

  • (String)

    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

Raises:

  • (ArgumentError.new)


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