Sha256: 2a798d567d0c8307136fdbbce7baed8a5d74db4be6c780b1bc05f7796ec58fde

Contents?: true

Size: 743 Bytes

Versions: 1

Compression:

Stored size: 743 Bytes

Contents

module Spotlight
  class CustomField < ActiveRecord::Base
    serialize :configuration, Hash
    belongs_to :exhibit

    before_save do
      self.field ||= field_name
    end

    def label=(label)
      configuration["label"] = label
    end

    def label
      configuration["label"]
    end

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

    def short_description
      configuration["short_description"]
    end
    
    protected 
    SUFFIX = '_tesim'.freeze
    def self.with_suffix(field)
      field.to_s + SUFFIX
    end

    private
    def field_name
      CustomField.with_suffix("exhibit_#{self.exhibit.to_param}_#{label.parameterize}")
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
blacklight-spotlight-0.0.3 app/models/spotlight/custom_field.rb