Sha256: beb00924e8975d2112963d8673140d7ef86ef175a20df34c8b8defb4c5474546

Contents?: true

Size: 1.54 KB

Versions: 9

Compression:

Stored size: 1.54 KB

Contents

module BlacklightAdvancedSearch
  autoload :Controller, 'blacklight_advanced_search/controller'
  autoload :RenderConstraintsOverride, 'blacklight_advanced_search/render_constraints_override'
  autoload :CatalogHelperOverride, 'blacklight_advanced_search/catalog_helper_override'
  autoload :QueryParser, 'blacklight_advanced_search/advanced_query_parser'
  autoload :ParsingNestingParser, 'blacklight_advanced_search/parsing_nesting_parser'
  autoload :FilterParser, 'blacklight_advanced_search/filter_parser'
  autoload :ParseBasicQ, 'blacklight_advanced_search/parse_basic_q'

  require 'blacklight_advanced_search/version'
  require 'blacklight_advanced_search/engine'

  
  # Utility method used in our solr search logic. 
  # Merges new_hash into source_hash, but will recursively
  # merge nested arrays and hashes too; also will NOT merge nil
  # or blank values from new_hash into source_hash, nil or blank values
  # in new_hash will not overwrite values in source_hash. 
  def self.deep_merge!(source_hash, new_hash)
    source_hash.merge!(new_hash) do |key, old, new|
      if new.respond_to?(:blank) && new.blank?
        old        
      elsif (old.kind_of?(Hash) and new.kind_of?(Hash))
        deep_merge!(old, new)
      elsif (old.kind_of?(Array) and new.kind_of?(Array))
        old.concat(new).uniq
      elsif new.nil?
        # Allowing nil values to over-write on merge messes things up.
        # don't set a nil value if you really want to force blank, set
        # empty string. 
        old
      else
        new
      end
    end
  end
  
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
blacklight_advanced_search-2.2.0 lib/blacklight_advanced_search.rb
blacklight_advanced_search-2.1.1 lib/blacklight_advanced_search.rb
blacklight_advanced_search-2.1.0 lib/blacklight_advanced_search.rb
blacklight_advanced_search-2.1.0.rc1 lib/blacklight_advanced_search.rb
blacklight_advanced_search-2.0.0 lib/blacklight_advanced_search.rb
blacklight_advanced_search-1.2.4 lib/blacklight_advanced_search.rb
blacklight_advanced_search-1.2.3 lib/blacklight_advanced_search.rb
blacklight_advanced_search-1.2.2 lib/blacklight_advanced_search.rb
blacklight_advanced_search-1.2.1 lib/blacklight_advanced_search.rb