Module: BlacklightFacetExtras::Pivot::ControllerExtension
- Defined in:
- lib/blacklight_facet_extras/pivot/controller_extension.rb
Overview
Meant to be applied on top of a controller that implements Blacklight::SolrHelper. Will inject pivot limiting behaviors to solr parameters creation.
Class Method Summary collapse
Instance Method Summary collapse
- #add_pivot_facets_to_solr(solr_parameters, user_parameters) ⇒ Object
- #blacklight_pivot_config ⇒ Object
- #facet_pivot_config(solr_field) ⇒ Object
Class Method Details
.included(some_class) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/blacklight_facet_extras/pivot/controller_extension.rb', line 6 def self.included(some_class) some_class.send :include,BlacklightFacetExtras::ControllerExtension some_class.helper_method :facet_pivot_config some_class.solr_search_params_logic << :add_pivot_facets_to_solr some_class.helper BlacklightFacetExtras::Pivot::ViewHelperExtension end |
Instance Method Details
#add_pivot_facets_to_solr(solr_parameters, user_parameters) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/blacklight_facet_extras/pivot/controller_extension.rb', line 12 def add_pivot_facets_to_solr(solr_parameters, user_parameters) blacklight_pivot_config.each do |k, config| solr_parameters[:"facet.field"].select { |x| x == k }.each do |x| solr_parameters[:"facet.field"].delete x end if solr_parameters[:"facet.field"] solr_parameters[:"facet.pivot"] ||= [] solr_parameters[:"facet.pivot"] << config.join(",") end solr_parameters end |
#blacklight_pivot_config ⇒ Object
32 33 34 |
# File 'lib/blacklight_facet_extras/pivot/controller_extension.rb', line 32 def blacklight_pivot_config Blacklight.config[:facet][:pivot] || {} end |
#facet_pivot_config(solr_field) ⇒ Object
26 27 28 29 30 |
# File 'lib/blacklight_facet_extras/pivot/controller_extension.rb', line 26 def facet_pivot_config(solr_field) config = blacklight_pivot_config[solr_field] || false config = {} if config == true config end |