Sha256: 576c85455c44c42ff072196cb2554e84ba4276a91005bbac8a6abc708bad5101

Contents?: true

Size: 688 Bytes

Versions: 58

Compression:

Stored size: 688 Bytes

Contents

##
# 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
    case field_type
    when 'vocab'
      Spotlight::Engine.config.solr_fields.string_suffix
    else
      Spotlight::Engine.config.solr_fields.text_suffix
    end
  end
end

Version data entries

58 entries across 58 versions & 1 rubygems

Version Path
blacklight-spotlight-2.4.1 app/values/custom_field_name.rb
blacklight-spotlight-2.4.0 app/values/custom_field_name.rb
blacklight-spotlight-2.3.3 app/values/custom_field_name.rb
blacklight-spotlight-2.3.2 app/values/custom_field_name.rb
blacklight-spotlight-2.3.1 app/values/custom_field_name.rb
blacklight-spotlight-2.3.0 app/values/custom_field_name.rb
blacklight-spotlight-2.2.1 app/values/custom_field_name.rb
blacklight-spotlight-2.2.0 app/values/custom_field_name.rb
blacklight-spotlight-2.1.0 app/values/custom_field_name.rb
blacklight-spotlight-2.0.2 app/values/custom_field_name.rb
blacklight-spotlight-2.0.1 app/values/custom_field_name.rb
blacklight-spotlight-2.0.0 app/values/custom_field_name.rb
blacklight-spotlight-2.0.0.rc6 app/values/custom_field_name.rb
blacklight-spotlight-2.0.0.rc5 app/values/custom_field_name.rb
blacklight-spotlight-2.0.0.rc4 app/values/custom_field_name.rb
blacklight-spotlight-2.0.0.rc3 app/values/custom_field_name.rb
blacklight-spotlight-2.0.0.rc2 app/values/custom_field_name.rb
blacklight-spotlight-2.0.0.rc1 app/values/custom_field_name.rb
blacklight-spotlight-1.5.1 app/values/custom_field_name.rb
blacklight-spotlight-1.4.1 app/values/custom_field_name.rb