Sha256: fd10d8c19eae2719cf92757bf960c64f43c7bd9c1362d257b3268e0c952d86d3

Contents?: true

Size: 1.19 KB

Versions: 21

Compression:

Stored size: 1.19 KB

Contents

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

  field :document_id,            type: String
  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_type_label,        type: String
  field :case_state,             type: String
  field :case_state_label,       type: String
  field :market_sector,          type: String
  field :market_sector_label,    type: String
  field :outcome_type,           type: String
  field :outcome_type_label,     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

21 entries across 21 versions & 1 rubygems

Version Path
govuk_content_models-11.3.0 app/models/rendered_specialist_document.rb
govuk_content_models-11.2.0 app/models/rendered_specialist_document.rb
govuk_content_models-11.1.0 app/models/rendered_specialist_document.rb
govuk_content_models-11.0.1 app/models/rendered_specialist_document.rb
govuk_content_models-11.0.0 app/models/rendered_specialist_document.rb
govuk_content_models-10.5.0 app/models/rendered_specialist_document.rb
govuk_content_models-10.4.2 app/models/rendered_specialist_document.rb
govuk_content_models-10.4.1 app/models/rendered_specialist_document.rb
govuk_content_models-10.4.0 app/models/rendered_specialist_document.rb
govuk_content_models-10.3.0 app/models/rendered_specialist_document.rb
govuk_content_models-10.2.2 app/models/rendered_specialist_document.rb
govuk_content_models-10.2.1 app/models/rendered_specialist_document.rb
govuk_content_models-10.2.0 app/models/rendered_specialist_document.rb
govuk_content_models-10.1.2 app/models/rendered_specialist_document.rb
govuk_content_models-10.1.1 app/models/rendered_specialist_document.rb
govuk_content_models-10.1.0 app/models/rendered_specialist_document.rb
govuk_content_models-10.0.0 app/models/rendered_specialist_document.rb
govuk_content_models-9.0.1 app/models/rendered_specialist_document.rb
govuk_content_models-9.0.0 app/models/rendered_specialist_document.rb
govuk_content_models-8.10.0 app/models/rendered_specialist_document.rb