Class: Chewy::Search::Parameters::Order

Inherits:
Storage
  • Object
show all
Defined in:
lib/chewy/search/parameters/order.rb

Overview

Sort parameter storage. Stores a hash of fields with the nil key if no options for the field were specified. Normalizer accepts an array of any hash-string-symbols combinations, or a hash.

Instance Attribute Summary

Attributes inherited from Storage

#value

Instance Method Summary collapse

Methods inherited from Storage

#==, #initialize, #merge!, #replace!

Constructor Details

This class inherits a constructor from Chewy::Search::Parameters::Storage

Instance Method Details

#render{Symbol => Array<Hash, String, Symbol>}

Size requires specialized rendering logic, it should return an array to satisfy ES.

Returns:

  • ({Symbol => Array<Hash, String, Symbol>})

See Also:



28
29
30
31
32
# File 'lib/chewy/search/parameters/order.rb', line 28

def render
  return if value.blank?

  {sort: value}
end

#update!(other_value) ⇒ Object

Merges two hashes.

Parameters:

  • other_value (Object)

    any acceptable storage value

Returns:

  • (Object)

    updated value

See Also:



19
20
21
# File 'lib/chewy/search/parameters/order.rb', line 19

def update!(other_value)
  value.concat(normalize(other_value))
end