module BlacklightAdvancedSearch

Returns a lambda that you can use with a before_filter in your CatalogController to catch and redirect query params using the old style, used prior to blacklight_advanced_search 5.0.

This can be used to keep any old bookmarked URLs still working.

before_filter BlacklightAdvancedSearch::RedirectLegacyParamsFilter, :only => :index

Constants

VERSION

Public Class Methods

deep_merge(source_hash, new_hash) click to toggle source

Utility method used in our solr search logic. Like Rails Hash#deep_merge, merges 2 hashes recursively, including nested Arrays and Hashes. Unlike Rails Hash#deep_merge:

  • will NOT merge nil values over existing ones

  • will NOT merge (non-FalseClass) blank values

  • WILL deduplicate values from arrays after merging them

@param [Hash|HashWithIndifferentAccess] source_hash @param [Hash|HashWithIndifferentAccess] new_hash @return [Hash] the deeply merged hash @see Rails deep_merge apidock.com/rails/v4.2.1/Hash/deep_merge @example new_hash = BlacklightAdvancedSearch.deep_merge(h1, h2)

# File lib/blacklight_advanced_search.rb, line 26
def self.deep_merge(source_hash, new_hash)
  source_hash.deep_merge(new_hash, &method(:merge_conflict_resolution))
end
deep_merge!(source_hash, new_hash) click to toggle source

this one side-effects the first param @see deep_merge @deprecated use `new_hash = BlacklightAdvancedSearch.deep_merge(h1, h2)` instead

# File lib/blacklight_advanced_search.rb, line 33
def self.deep_merge!(source_hash, new_hash)
  source_hash.deep_merge!(new_hash, &method(:merge_conflict_resolution))
end
merge_conflict_resolution(_key, old, new_value) click to toggle source

the arguments are set by what the Rails Hash.deep_merge supplies the block

# File lib/blacklight_advanced_search.rb, line 38
def self.merge_conflict_resolution(_key, old, new_value)
  return old if new_value.nil?
  return old if new_value.respond_to?(:blank?) && new_value.blank? && !new_value.is_a?(FalseClass)
  return old | new_value if old.is_a?(Array) && new_value.is_a?(Array)
  new_value
end
version() click to toggle source
# File lib/blacklight_advanced_search/version.rb, line 3
def self.version
  @version ||= File.read(File.join(File.dirname(__FILE__), '..', '..', 'VERSION')).chomp
end