Class: ContentBlock

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/content_block.rb

Constant Summary collapse

MARKETING =
'marketing_text'.freeze
RESEARCHER =
'featured_researcher'.freeze
ANNOUNCEMENT =
'announcement_text'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.announcement_textObject



14
15
16
# File 'app/models/content_block.rb', line 14

def self.announcement_text
  find_or_create_by(name: ANNOUNCEMENT)
end

.announcement_text=(value) ⇒ Object



18
19
20
# File 'app/models/content_block.rb', line 18

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

.external_keysObject



34
35
36
# File 'app/models/content_block.rb', line 34

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


26
27
28
# File 'app/models/content_block.rb', line 26

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


30
31
32
# File 'app/models/content_block.rb', line 30

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

.marketing_textObject



6
7
8
# File 'app/models/content_block.rb', line 6

def self.marketing_text
  find_or_create_by(name: MARKETING)
end

.marketing_text=(value) ⇒ Object



10
11
12
# File 'app/models/content_block.rb', line 10

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

.recent_researchersObject



22
23
24
# File 'app/models/content_block.rb', line 22

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

Instance Method Details

#external_key_nameObject



38
39
40
# File 'app/models/content_block.rb', line 38

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