Class: Pulitzer::ContentElement
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Pulitzer::ContentElement
- Defined in:
- app/models/pulitzer/content_element.rb
Instance Attribute Summary collapse
-
#ensure_unique ⇒ Object
Returns the value of attribute ensure_unique.
-
#version_unavailable ⇒ Object
Returns the value of attribute version_unavailable.
Instance Method Summary collapse
- #clone_image(clone_attrs) ⇒ Object
- #clone_me ⇒ Object
- #empty_body? ⇒ Boolean
- #has_content? ⇒ Boolean
- #html ⇒ Object
-
#video_link ⇒ Object
def reprocess_versions! self.photo.recreate_versions! self.broadcast_change end.
Instance Attribute Details
#ensure_unique ⇒ Object
Returns the value of attribute ensure_unique.
14 15 16 |
# File 'app/models/pulitzer/content_element.rb', line 14 def ensure_unique @ensure_unique end |
#version_unavailable ⇒ Object
Returns the value of attribute version_unavailable.
14 15 16 |
# File 'app/models/pulitzer/content_element.rb', line 14 def version_unavailable @version_unavailable end |
Instance Method Details
#clone_image(clone_attrs) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'app/models/pulitzer/content_element.rb', line 69 def clone_image(clone_attrs) clone_attrs.delete 'image' my_clone = Pulitzer::ContentElement.new(clone_attrs) if image.file && image.file.exists? my_clone.remote_image_url = image.url # If there is an error getting the image, don't bail out, # create the content element clone without the image so the user can reupload later if !my_clone.valid? if my_clone.errors.get(:image) my_clone = Pulitzer::ContentElement.new(clone_attrs) end end end my_clone.save! my_clone end |
#clone_me ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/models/pulitzer/content_element.rb', line 54 def clone_me clone_attrs = self.attributes.dup clone_attrs.delete 'id' clone_attrs.delete 'version_id' type_clone_method = 'clone_' + type.to_s if respond_to? type_clone_method my_clone = send type_clone_method, clone_attrs else my_clone = Pulitzer::ContentElement.create!(clone_attrs) end my_clone end |
#empty_body? ⇒ Boolean
46 47 48 |
# File 'app/models/pulitzer/content_element.rb', line 46 def empty_body? image_type? ? !image? : body.blank? end |
#has_content? ⇒ Boolean
50 51 52 |
# File 'app/models/pulitzer/content_element.rb', line 50 def has_content? image_type? ? image? : body.present? end |
#html ⇒ Object
42 43 44 |
# File 'app/models/pulitzer/content_element.rb', line 42 def html body.blank? ? "" : body.html_safe end |
#video_link ⇒ Object
def reprocess_versions!
self.photo.recreate_versions!
self.broadcast_change
end
36 37 38 39 40 |
# File 'app/models/pulitzer/content_element.rb', line 36 def video_link if video_type? && !body.nil? vimeo_video(body) || youtube_video(body) end end |