Class: ContentBlock
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ContentBlock
- 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
- .announcement_text ⇒ Object
- .announcement_text=(value) ⇒ Object
- .external_keys ⇒ Object
- .featured_researcher ⇒ Object
- .featured_researcher=(value) ⇒ Object
- .marketing_text ⇒ Object
- .marketing_text=(value) ⇒ Object
- .recent_researchers ⇒ Object
Instance Method Summary collapse
Class Method Details
.announcement_text ⇒ Object
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_keys ⇒ Object
34 35 36 |
# File 'app/models/content_block.rb', line 34 def self.external_keys { RESEARCHER => 'User' } end |
.featured_researcher ⇒ Object
26 27 28 |
# File 'app/models/content_block.rb', line 26 def self.featured_researcher recent_researchers.first_or_create(name: RESEARCHER) end |
.featured_researcher=(value) ⇒ Object
30 31 32 |
# File 'app/models/content_block.rb', line 30 def self.featured_researcher=(value) create(name: RESEARCHER, value: value) end |
.marketing_text ⇒ Object
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_researchers ⇒ Object
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_name ⇒ Object
38 39 40 |
# File 'app/models/content_block.rb', line 38 def external_key_name self.class.external_keys.fetch(name) { 'External Key' } end |