lib/blacklight/configuration/fields.rb in blacklight-6.5.0 vs lib/blacklight/configuration/fields.rb in blacklight-6.6.0

- old
+ new

@@ -5,11 +5,10 @@ # solr fields configuration module Fields extend ActiveSupport::Concern module ClassMethods - # Add a configuration block for a collection of solr fields def define_field_access(key, options = {}) key = key.to_s if respond_to? :to_s self.default_values[key.pluralize.to_sym] = ActiveSupport::OrderedHash.new @@ -37,38 +36,54 @@ # # Alternative formats include: # # * a field name and block format: # + # @overload add_blacklight_field(config_key, field_key) + # @param [Symbol] config_key + # @param [Symbol,String] field_key + # + # # add_blacklight_field :index_field, 'format' do |field| # field.label = 'Format' # end # # * a plain block: # + # @overload add_blacklight_field(config_key) + # @param [Symbol] config_key + # # add_blacklight_field :index_field do |field| # field.field = 'format' # field.label = 'Format' # end # # * a configuration hash: # + # @overload add_blacklight_field(config_key, options) + # @param [Symbol] config_key + # @param [Hash] options + # # add_blacklight_field :index_field, :field => 'format', :label => 'Format' # # * a Field instance: # + # @overload add_blacklight_field(config_key, field) + # @param [Symbol] config_key + # @param [Blacklight::Configuration::Field] field + # + # # add_blacklight_field :index_field, IndexField.new(:field => 'format', :label => 'Format') # # * an array of hashes: # - # add_blacklight_field :index_field, [{:field => 'format', :label => 'Format'}, IndexField.new(:field => 'date', :label => 'Date')] + # @overload add_blacklight_field(config_key, fields) + # @param [Symbol] config_key + # @param [Array<Blacklight::Configuration::Field, Hash>] fields # + # add_blacklight_field :index_field, [{ :field => 'format', :label => 'Format' }, IndexField.new(:field => 'date', :label => 'Date')] # - # @param String config_key - # @param Array *args - # @para - # 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 @@ -119,12 +134,13 @@ self[config_key.pluralize][ field_config.key ] = field_config end protected + def luke_fields - if @table[:luke_fields] === false + if @table[:luke_fields] == false return nil end @table[:luke_fields] ||= Rails.cache.fetch("blacklight_configuration/admin/luke", expires_in: 1.hour) do begin @@ -177,9 +193,10 @@ hash_arg end end private + # convert a config key to the appropriate Field class def field_class_from_key key "Blacklight::Configuration::#{key.camelcase}".constantize end end