Class: Pulitzer::ContentElement
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
assoc_name, attrs_name, convert_hash_to_nested, convert_nested_assoc
Instance Attribute Details
#ensure_unique ⇒ Object
Returns the value of attribute ensure_unique.
19
20
21
|
# File 'app/models/pulitzer/content_element.rb', line 19
def ensure_unique
@ensure_unique
end
|
#version_unavailable ⇒ Object
Returns the value of attribute version_unavailable.
19
20
21
|
# File 'app/models/pulitzer/content_element.rb', line 19
def version_unavailable
@version_unavailable
end
|
Class Method Details
.export_config ⇒ Object
def reprocess_versions!
self.photo.recreate_versions!
self.broadcast_change
end
40
41
42
|
# File 'app/models/pulitzer/content_element.rb', line 40
def self.export_config
{ except: [:id, :image, :post_type_content_element_type_id, :version_id, :style_id, :partial_id, :custom_option_id, :created_at, :updated_at]}
end
|
Instance Method Details
#clone_image(clone_attrs) ⇒ Object
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
# File 'app/models/pulitzer/content_element.rb', line 129
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 !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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
# File 'app/models/pulitzer/content_element.rb', line 114
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
|
#content ⇒ Object
76
77
78
79
80
81
82
|
# File 'app/models/pulitzer/content_element.rb', line 76
def content
if custom_type?
custom_content
else
body
end
end
|
#content_display ⇒ Object
84
85
86
87
88
89
90
|
# File 'app/models/pulitzer/content_element.rb', line 84
def content_display
if custom_type?
custom_display
else
body
end
end
|
#custom_content ⇒ Object
68
69
70
|
# File 'app/models/pulitzer/content_element.rb', line 68
def custom_content
custom_option.value
end
|
#custom_display ⇒ Object
72
73
74
|
# File 'app/models/pulitzer/content_element.rb', line 72
def custom_display
"#{custom_option.display} #{custom_option.custom_option_list.name.singularize}"
end
|
#custom_type? ⇒ Boolean
92
93
94
|
# File 'app/models/pulitzer/content_element.rb', line 92
def custom_type?
custom_option.present?
end
|
#empty_body? ⇒ Boolean
54
55
56
|
# File 'app/models/pulitzer/content_element.rb', line 54
def empty_body?
!has_content?
end
|
#has_content? ⇒ Boolean
58
59
60
61
62
63
64
65
66
|
# File 'app/models/pulitzer/content_element.rb', line 58
def has_content?
if image_type?
image?
elsif custom_type?
custom_content.present?
else
body.present?
end
end
|
#html ⇒ Object
50
51
52
|
# File 'app/models/pulitzer/content_element.rb', line 50
def html
body.blank? ? "" : body.html_safe
end
|
#style_display ⇒ Object
110
111
112
|
# File 'app/models/pulitzer/content_element.rb', line 110
def style_display
style&.display_name
end
|
#style_options ⇒ Object
106
107
108
|
# File 'app/models/pulitzer/content_element.rb', line 106
def style_options
post_type_content_element_type.styles
end
|
#video_link ⇒ Object
44
45
46
47
48
|
# File 'app/models/pulitzer/content_element.rb', line 44
def video_link
if video_type? && !body.nil?
vimeo_video(body) || youtube_video(body)
end
end
|