Sha256: 2788422d9e0b2d92f076795b803d9dc6aaf0ece07db41aba161f9dae074e6a96

Contents?: true

Size: 894 Bytes

Versions: 3

Compression:

Stored size: 894 Bytes

Contents

class RenderedSpecialistDocument
  include Mongoid::Document
  include Mongoid::Timestamps

  field :slug,          type: String
  field :title,         type: String
  field :summary,       type: String
  field :body,          type: String
  field :opened_date,   type: Date
  field :closed_date,   type: Date
  field :case_type,     type: String
  field :case_state,    type: String
  field :market_sector, type: String
  field :outcome_type,  type: String
  field :headers,       type: Array

  index "slug", unique: true

  GOVSPEAK_FIELDS = []

  validates :slug, uniqueness: true
  validates_with SafeHtml

  def self.create_or_update_by_slug!(attributes)
    RenderedSpecialistDocument.find_or_initialize_by(
      slug: attributes.fetch(:slug)
    ).tap do |doc|
      doc.update_attributes!(attributes)
    end
  end

  def self.find_by_slug(slug)
    where(slug: slug).first
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
govuk_content_models-8.8.0 app/models/rendered_specialist_document.rb
govuk_content_models-8.7.0 app/models/rendered_specialist_document.rb
govuk_content_models-8.6.0 app/models/rendered_specialist_document.rb