Class: Spotlight::CustomField

Inherits:
ActiveRecord::Base
  • Object
show all
Extended by:
FriendlyId
Defined in:
app/models/spotlight/custom_field.rb

Overview

Exhibit custom fields

Instance Method Summary collapse

Instance Method Details

#configured_to_display?Boolean

Returns:

  • (Boolean)


53
54
55
56
57
58
59
# File 'app/models/spotlight/custom_field.rb', line 53

def configured_to_display?
  index_fields_config &&
    index_fields_config['enabled'] &&
    view_types.any? do |view|
      index_fields_config[view.to_s]
    end
end

#labelObject



36
37
38
39
40
41
42
43
# File 'app/models/spotlight/custom_field.rb', line 36

def label
  conf = if field && blacklight_configuration&.index_fields&.key?(field)
           blacklight_configuration.index_fields[field].reverse_merge(configuration)
         else
           configuration
         end
  conf['label'] || conf[:label]
end

#label=(label) ⇒ Object



30
31
32
33
34
# File 'app/models/spotlight/custom_field.rb', line 30

def label=(label)
  configuration['label'] = label

  update_blacklight_configuration_label label
end

#short_descriptionObject



49
50
51
# File 'app/models/spotlight/custom_field.rb', line 49

def short_description
  configuration['short_description']
end

#short_description=(short_description) ⇒ Object



45
46
47
# File 'app/models/spotlight/custom_field.rb', line 45

def short_description=(short_description)
  configuration['short_description'] = short_description
end

#solr_fieldObject



61
62
63
64
65
66
67
68
# File 'app/models/spotlight/custom_field.rb', line 61

def solr_field
  if field&.starts_with?(solr_field_prefix)
    # backwards compatibility with pre-0.9 custom fields
    field
  else
    "#{solr_field_prefix}#{field || field_name}"
  end
end