Sha256: 5c2630c0df3d719d195663f46fa07a6682ce1c1ba7844c457a2023a7eb784983

Contents?: true

Size: 762 Bytes

Versions: 17

Compression:

Stored size: 762 Bytes

Contents

# frozen_string_literal: true

##
# Value object for calculating a custom field name.
class CustomFieldName
  delegate :readonly_field?, :configuration, :field_type, to: :custom_field
  attr_reader :custom_field
  def initialize(custom_field)
    @custom_field = custom_field
  end

  def to_s
    "#{field_slug}#{field_suffix}"
  end

  private

  def field_slug
    "#{field_prefix}#{configuration['label'].parameterize}"
  end

  def field_prefix
    if readonly_field?
      'readonly_'
    else
      ''
    end
  end

  def field_suffix
    (field_type && Spotlight::Engine.config.custom_field_types[field_type.to_sym][:suffix]) ||
      default_field_suffix
  end

  def default_field_suffix
    Spotlight::Engine.config.solr_fields.text_suffix
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
blacklight-spotlight-3.0.0.alpha.10 app/values/custom_field_name.rb
blacklight-spotlight-3.0.0.alpha.9 app/values/custom_field_name.rb
blacklight-spotlight-3.0.0.alpha.8 app/values/custom_field_name.rb
blacklight-spotlight-3.0.0.alpha.7 app/values/custom_field_name.rb
blacklight-spotlight-3.0.0.alpha.6 app/values/custom_field_name.rb
blacklight-spotlight-3.0.0.alpha.5 app/values/custom_field_name.rb
blacklight-spotlight-3.0.0.alpha.4 app/values/custom_field_name.rb
blacklight-spotlight-3.0.0.alpha.3 app/values/custom_field_name.rb
blacklight-spotlight-3.0.0.alpha.2 app/values/custom_field_name.rb
blacklight-spotlight-3.0.0.alpha.1 app/values/custom_field_name.rb
blacklight-spotlight-2.13.0 app/values/custom_field_name.rb
blacklight-spotlight-2.12.1 app/values/custom_field_name.rb
blacklight-spotlight-2.12.0 app/values/custom_field_name.rb
blacklight-spotlight-2.11.0 app/values/custom_field_name.rb
blacklight-spotlight-2.10.0 app/values/custom_field_name.rb
blacklight-spotlight-2.9.0 app/values/custom_field_name.rb
blacklight-spotlight-2.8.0 app/values/custom_field_name.rb