Sha256: a4e5cee40c329a892cd6c066eab6c54b3244e23dfdb299e5cd1a94941d05dd66
Contents?: true
Size: 911 Bytes
Versions: 1
Compression:
Stored size: 911 Bytes
Contents
class AuthorFieldType < FieldType attr_accessor :author_name jsonb_accessor :data, author_name: :string validates :author_name, presence: true, if: :validate_presence? def data=(data_hash) data_hash[:author_name] = data_hash[:default_author_name] if data_hash.deep_symbolize_keys[:author_name].blank? @author_name = data_hash.deep_symbolize_keys[:author_name] end def field_item_as_indexed_json_for_field_type(field_item, options = {}) json = {} json[mapping_field_name] = field_item.data['author_name'] json end def mapping { name: mapping_field_name, type: :string, analyzer: :snowball } end private def mapping_field_name "#{field_name.parameterize(separator: '_')}_author" end def author_name_present errors.add(:author_name, 'must be present') if @author_name.empty? end def validate_presence? @validations.key? :presence end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cortex-plugins-core-0.12.4 | app/models/author_field_type.rb |