Sha256: c3db2dde46adde1e7be461679ed86fd8c200714adf56ed0be629017a37bbdb7b

Contents?: true

Size: 915 Bytes

Versions: 8

Compression:

Stored size: 915 Bytes

Contents

class ContentBlock < ActiveRecord::Base
  MARKETING  = 'marketing_text'.freeze
  RESEARCHER = 'featured_researcher'.freeze
  ANNOUNCEMENT = 'announcement_text'.freeze

  def self.marketing_text
    find_or_create_by(name: MARKETING)
  end

  def self.marketing_text=(value)
    marketing_text.update(value: value)
  end

  def self.announcement_text
    find_or_create_by(name: ANNOUNCEMENT)
  end

  def self.announcement_text=(value)
    announcement_text.update(value: value)
  end

  def self.recent_researchers
    where(name: RESEARCHER).order('created_at DESC')
  end

  def self.featured_researcher
    recent_researchers.first_or_create(name: RESEARCHER)
  end

  def self.featured_researcher=(value)
    create(name: RESEARCHER, value: value)
  end

  def self.external_keys
    { RESEARCHER => 'User' }
  end

  def external_key_name
    self.class.external_keys.fetch(name) { 'External Key' }
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
sufia-7.1.0 app/models/content_block.rb
sufia-7.0.0 app/models/content_block.rb
sufia-7.0.0.rc2 app/models/content_block.rb
sufia-7.0.0.rc1 app/models/content_block.rb
sufia-7.0.0.beta4 app/models/content_block.rb
sufia-7.0.0.beta3 app/models/content_block.rb
sufia-7.0.0.beta2 app/models/content_block.rb
sufia-7.0.0.beta1 app/models/content_block.rb