Module: Blacklight::Facet
- Included in:
- Catalog, FacetsHelperBehavior, JsonPresenter
- Defined in:
- app/controllers/concerns/blacklight/facet.rb
Overview
These are methods that are used at both the view helper and controller layers They are only dependent on `blacklight_config` and `@response`
Instance Method Summary collapse
-
#facet_by_field_name(field_or_field_name) ⇒ Object
Get a FacetField object from the @response.
- #facet_field_names ⇒ Object
- #facet_paginator(field_config, response_data) ⇒ Object
- #facets_from_request(fields = facet_field_names) ⇒ Object
Instance Method Details
#facet_by_field_name(field_or_field_name) ⇒ Object
Get a FacetField object from the @response
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/concerns/blacklight/facet.rb', line 28 def facet_by_field_name(field_or_field_name) case field_or_field_name when String, Symbol facet_field = facet_configuration_for_field(field_or_field_name) @response.aggregations[facet_field.field] when Blacklight::Configuration::FacetField @response.aggregations[field_or_field_name.field] else # is this really a useful case? field_or_field_name end end |
#facet_field_names ⇒ Object
23 24 25 |
# File 'app/controllers/concerns/blacklight/facet.rb', line 23 def facet_field_names blacklight_config.facet_fields.values.map(&:field) end |
#facet_paginator(field_config, response_data) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'app/controllers/concerns/blacklight/facet.rb', line 9 def facet_paginator(field_config, response_data) blacklight_config.facet_paginator_class.new( response_data.items, sort: response_data.sort, offset: response_data.offset, prefix: response_data.prefix, limit: facet_limit_for(field_config.key) ) end |
#facets_from_request(fields = facet_field_names) ⇒ Object
19 20 21 |
# File 'app/controllers/concerns/blacklight/facet.rb', line 19 def facets_from_request(fields = facet_field_names) fields.map { |field| facet_by_field_name(field) }.compact end |