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)


46
47
48
49
50
51
52
# File 'app/models/spotlight/custom_field.rb', line 46

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



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

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

#label=(label) ⇒ Object



23
24
25
26
27
# File 'app/models/spotlight/custom_field.rb', line 23

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

  update_blacklight_configuration_label label
end

#short_descriptionObject



42
43
44
# File 'app/models/spotlight/custom_field.rb', line 42

def short_description
  configuration['short_description']
end

#short_description=(short_description) ⇒ Object



38
39
40
# File 'app/models/spotlight/custom_field.rb', line 38

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

#solr_fieldObject



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

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