Sha256: 6102903e7227982c3250342c54dfdc6425391b7845381ae7c39ab815cdfbd51a

Contents?: true

Size: 669 Bytes

Versions: 10

Compression:

Stored size: 669 Bytes

Contents

class TagFieldType < FieldType
  attr_accessor :tag_list

  validates :tag_list, presence: true, if: :validate_presence?

  def data=(data_hash)
    @tag_list = data_hash.deep_symbolize_keys[:tag_list]
    @tag_list.nil? ? nil : (@tag_list = @tag_list.split(","))
  end

  def field_item_as_indexed_json_for_field_type(field_item, options = {})
    json = {}
    json[mapping_field_name] = field_item.data['tag']
    json
  end

  def mapping
    {name: mapping_field_name, type: :string, analyzer: :snowball}
  end

  private

  def mapping_field_name
    "#{field_name.parameterize('_')}_tag"
  end

  def validate_presence?
    @validations.key? :presence
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
cortex-plugins-core-0.5.0 app/models/tag_field_type.rb
cortex-plugins-core-0.4.8 app/models/tag_field_type.rb
cortex-plugins-core-0.4.7 app/models/tag_field_type.rb
cortex-plugins-core-0.4.6 app/models/tag_field_type.rb
cortex-plugins-core-0.4.5 app/models/tag_field_type.rb
cortex-plugins-core-0.4.4 app/models/tag_field_type.rb
cortex-plugins-core-0.4.3 app/models/tag_field_type.rb
cortex-plugins-core-0.4.2 app/models/tag_field_type.rb
cortex-plugins-core-0.4.1 app/models/tag_field_type.rb
cortex-plugins-core-0.4.0 app/models/tag_field_type.rb