Class: Pulitzer::Post
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Pulitzer::Post
- Extended by:
- FriendlyId
- Includes:
- ForeignOffice::Broadcaster
- Defined in:
- app/models/pulitzer/post.rb
Constant Summary collapse
- TAG_MODELS =
["Pulitzer::Tag"] + Pulitzer.tagging_models
Instance Attribute Summary collapse
-
#new_preview_version ⇒ Object
Returns the value of attribute new_preview_version.
Instance Method Summary collapse
- #content_element(label) ⇒ Object
- #create_preview_version ⇒ Object
- #create_processing_version ⇒ Object
- #next_version ⇒ Object
- #preview_version ⇒ Object
- #processing_failed_version ⇒ Object
- #processing_version ⇒ Object
- #serialize ⇒ Object
- #should_generate_new_friendly_id? ⇒ Boolean
- #tags ⇒ Object
Instance Attribute Details
#new_preview_version ⇒ Object
Returns the value of attribute new_preview_version.
17 18 19 |
# File 'app/models/pulitzer/post.rb', line 17 def new_preview_version @new_preview_version end |
Instance Method Details
#content_element(label) ⇒ Object
27 28 29 30 31 |
# File 'app/models/pulitzer/post.rb', line 27 def content_element(label) if content_elements self.content_elements.find_by(label: label) end end |
#create_preview_version ⇒ Object
53 54 55 |
# File 'app/models/pulitzer/post.rb', line 53 def create_preview_version versions.create(status: :preview) end |
#create_processing_version ⇒ Object
57 58 59 |
# File 'app/models/pulitzer/post.rb', line 57 def create_processing_version versions.create(status: :processing) end |
#next_version ⇒ Object
49 50 51 |
# File 'app/models/pulitzer/post.rb', line 49 def next_version preview_version || processing_version || processing_failed_version end |
#preview_version ⇒ Object
37 38 39 |
# File 'app/models/pulitzer/post.rb', line 37 def preview_version versions.preview.last end |
#processing_failed_version ⇒ Object
45 46 47 |
# File 'app/models/pulitzer/post.rb', line 45 def processing_failed_version versions.processing_failed.last end |
#processing_version ⇒ Object
41 42 43 |
# File 'app/models/pulitzer/post.rb', line 41 def processing_version versions.processing.last end |
#serialize ⇒ Object
61 62 63 64 |
# File 'app/models/pulitzer/post.rb', line 61 def serialize self.attributes.merge \ new_preview_version: self.new_preview_version end |
#should_generate_new_friendly_id? ⇒ Boolean
33 34 35 |
# File 'app/models/pulitzer/post.rb', line 33 def should_generate_new_friendly_id? new_record? || title_changed? end |
#tags ⇒ Object
23 24 25 |
# File 'app/models/pulitzer/post.rb', line 23 def .map(&:label) end |