Class: Chewy::Search::Parameters::IndicesBoost
- Defined in:
- lib/chewy/search/parameters/indices_boost.rb
Overview
Stores provided values as a string-float hash, but also takes keys order into account.
Instance Attribute Summary
Attributes inherited from Storage
Instance Method Summary collapse
- 
  
    
      #==(other)  ⇒ true, false 
    
    
  
  
  
  
  
  
  
  
  
    Comparison also reqires additional logic. 
- 
  
    
      #render  ⇒ Array<{String => Float}> 
    
    
  
  
  
  
  
  
  
  
  
    Renders the value hash as an array of hashes for each key-value pair. 
- 
  
    
      #update!(other_value)  ⇒ {String => Float} 
    
    
  
  
  
  
  
  
  
  
  
    Merges two hashes, but puts keys from the second hash at the end of the result hash. 
Methods inherited from Storage
#initialize, #merge!, #replace!
Constructor Details
This class inherits a constructor from Chewy::Search::Parameters::Storage
Instance Method Details
#==(other) ⇒ true, false
Comparison also reqires additional logic. Since indexes boost is sensitive to the order index templates are provided, we have to compare stored hashes keys as well.
| 38 39 40 | # File 'lib/chewy/search/parameters/indices_boost.rb', line 38 def ==(other) super && value.keys == other.value.keys end | 
#render ⇒ Array<{String => Float}>
Renders the value hash as an array of hashes for each key-value pair.
| 28 29 30 | # File 'lib/chewy/search/parameters/indices_boost.rb', line 28 def render {self.class.param_name => value.map { |k, v| {k => v} }} if value.present? end | 
#update!(other_value) ⇒ {String => Float}
Merges two hashes, but puts keys from the second hash at the end of the result hash.
| 18 19 20 21 | # File 'lib/chewy/search/parameters/indices_boost.rb', line 18 def update!(other_value) new_value = normalize(other_value) value.except!(*new_value.keys).merge!(new_value) end |