lib/blacklight/configuration/fields.rb in blacklight-7.40.0 vs lib/blacklight/configuration/fields.rb in blacklight-8.0.0.beta1
- old
+ new
@@ -1,14 +1,13 @@
# frozen_string_literal: true
+
module Blacklight
class Configuration
# This mixin provides Blacklight::Configuration with generic
# solr fields configuration
module Fields
extend ActiveSupport::Concern
- extend Deprecation
- self.deprecation_horizon = 'blacklight version 8.0.0'
class_methods do
# Add a configuration block for a collection of solr fields
def define_field_access(key, base_class_name = nil, class: nil)
key = key.to_s if respond_to? :to_s
@@ -82,24 +81,24 @@
#
# add_blacklight_field :index_field, [{ :field => 'format', :label => 'Format' }, IndexField.new(:field => 'date', :label => 'Date')]
#
def add_blacklight_field config_key, *args, &block
field_config = case args.first
- when String
- field_config_from_key_and_hash(config_key, *args)
- when Symbol
- args[0] = args[0].to_s
- field_config_from_key_and_hash(config_key, *args)
- when Array
- field_config_from_array(config_key, *args, &block)
- return # we've iterated over the array above.
- else
- field_config_from_field_or_hash(config_key, *args)
+ when String
+ field_config_from_key_and_hash(config_key, *args)
+ when Symbol
+ args[0] = args[0].to_s
+ field_config_from_key_and_hash(config_key, *args)
+ when Array
+ field_config_from_array(config_key, *args, &block)
+ return # we've iterated over the array above.
+ else
+ field_config_from_field_or_hash(config_key, *args)
end
if (field_config.field || field_config.key).to_s =~ /\*/
- field_config.match = Regexp.new("^" + (field_config.field || field_config.key).to_s.gsub('*', '.+') + "$")
+ field_config.match = Regexp.new("^#{(field_config.field || field_config.key).to_s.gsub('*', '.+')}$")
end
# look up any dynamic fields
if field_config.match
handle_matching_fields(config_key, field_config, &block)
@@ -153,11 +152,9 @@
false
end
@table[:reflected_fields] || {}
end
- alias luke_fields reflected_fields
- deprecation_deprecate luke_fields: 'use reflected_fields instead'
# Add a solr field by a solr field name and hash
def field_config_from_key_and_hash config_key, field_name, field_or_hash = {}
field_config = field_config_from_field_or_hash(config_key, field_or_hash)
field_config.key = field_name