Sha256: 0ea24e1f4966b6a7f3b65d2d508b69c096fd688bee32eff12eabe5e9cc0e025b
Contents?: true
Size: 1.91 KB
Versions: 24
Compression:
Stored size: 1.91 KB
Contents
module Spotlight ## # Helpers to provide default blacklight configuration values module BlacklightConfigurationDefaults extend ActiveSupport::Concern included do before_create :setup_defaults attr_accessor :skip_default_configuration end protected def setup_defaults return if skip_default_configuration default_search_fields default_sort_fields default_view_types set_default_per_page end def default_search_fields return true unless search_fields.empty? # can't use default_blacklight_config until after the BlacklightConfiguration # is created or we run into a circular dependency. default_fields = Spotlight::Engine.blacklight_config.search_fields self.search_fields = default_fields.each_with_object({}) do |(k, v), obj| obj[k] = { enabled: v.fetch(:enabled, true) } end end def default_sort_fields return true unless sort_fields.empty? # can't use default_blacklight_config until after the BlacklightConfiguration # is created or we run into a circular dependency. default_fields = Spotlight::Engine.blacklight_config.sort_fields self.sort_fields = default_fields.each_with_object({}) do |(k, v), obj| obj[k] = { enabled: v.fetch(:enabled, true) } end end def default_view_types return true unless document_index_view_types.empty? # can't use default_blacklight_config until after the BlacklightConfiguration # is created or we run into a circular dependency. self.document_index_view_types = Spotlight::Engine.blacklight_config.view.keys.map(&:to_s) end def set_default_per_page # can't use default_blacklight_config until after the BlacklightConfiguration # is created or we run into a circular dependency. self.default_per_page ||= Spotlight::Engine.blacklight_config.per_page.first end end end
Version data entries
24 entries across 24 versions & 1 rubygems