Module: BlacklightAdvancedSearch

Defined in:
lib/blacklight_advanced_search/redirect_legacy_params_filter.rb,
lib/blacklight_advanced_search.rb,
lib/blacklight_advanced_search/engine.rb,
lib/blacklight_advanced_search/version.rb,
lib/blacklight_advanced_search/advanced_query_parser.rb,
lib/blacklight_advanced_search/advanced_search_builder.rb,
lib/generators/blacklight_advanced_search/assets_generator.rb,
lib/generators/blacklight_advanced_search/install_generator.rb,
app/helpers/blacklight_advanced_search/advanced_helper_behavior.rb

Overview

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

Defined Under Namespace

Modules: AdvancedHelperBehavior, AdvancedSearchBuilder, CatalogHelperOverride, Controller, FilterParser, ParsingNestingParser, RenderConstraintsOverride Classes: AdvancedController, AssetsGenerator, Engine, InstallGenerator, QueryParser, RedirectLegacyParamsFilter

Constant Summary collapse

VERSION =
self.version

Class Method Summary collapse

Class Method Details

.deep_merge(source_hash, new_hash) ⇒ Hash

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

Examples:

new_hash = BlacklightAdvancedSearch.deep_merge(h1, h2)

Parameters:

  • source_hash (Hash|HashWithIndifferentAccess)
  • new_hash (Hash|HashWithIndifferentAccess)

Returns:

  • (Hash)

    the deeply merged hash

See Also:

  • #deep_merge http://apidock.com/rails/v4.2.1/Hash/deep_merge

26
27
28
# 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) ⇒ Object

Deprecated.

use `new_hash = BlacklightAdvancedSearch.deep_merge(h1, h2)` instead

this one side-effects the first param

See Also:

  • #deep_merge

33
34
35
# 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) ⇒ Object

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


38
39
40
41
42
43
# 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

.versionObject


3
4
5
# File 'lib/blacklight_advanced_search/version.rb', line 3

def self.version
  @version ||= File.read(File.join(File.dirname(__FILE__), '..', '..', 'VERSION')).chomp
end