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.
18
19
20
|
# File 'app/models/pulitzer/content_element.rb', line 18
def ensure_unique
@ensure_unique
end
|
#version_unavailable ⇒ Object
Returns the value of attribute version_unavailable.
18
19
20
|
# File 'app/models/pulitzer/content_element.rb', line 18
def version_unavailable
@version_unavailable
end
|
Class Method Details
.export_config ⇒ Object
def reprocess_versions!
self.photo.recreate_versions!
self.broadcast_change
end
39
40
41
|
# File 'app/models/pulitzer/content_element.rb', line 39
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
# File 'app/models/pulitzer/content_element.rb', line 128
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
# File 'app/models/pulitzer/content_element.rb', line 113
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
75
76
77
78
79
80
81
|
# File 'app/models/pulitzer/content_element.rb', line 75
def content
if custom_type?
custom_content
else
body
end
end
|
#content_display ⇒ Object
83
84
85
86
87
88
89
|
# File 'app/models/pulitzer/content_element.rb', line 83
def content_display
if custom_type?
custom_display
else
body
end
end
|
#custom_content ⇒ Object
67
68
69
|
# File 'app/models/pulitzer/content_element.rb', line 67
def custom_content
custom_option.value
end
|
#custom_display ⇒ Object
71
72
73
|
# File 'app/models/pulitzer/content_element.rb', line 71
def custom_display
"#{custom_option.display} #{custom_option.custom_option_list.name.singularize}"
end
|
#custom_type? ⇒ Boolean
91
92
93
|
# File 'app/models/pulitzer/content_element.rb', line 91
def custom_type?
custom_option.present?
end
|
#empty_body? ⇒ Boolean
53
54
55
|
# File 'app/models/pulitzer/content_element.rb', line 53
def empty_body?
!has_content?
end
|
#has_content? ⇒ Boolean
57
58
59
60
61
62
63
64
65
|
# File 'app/models/pulitzer/content_element.rb', line 57
def has_content?
if image_type?
image?
elsif custom_type?
custom_content.present?
else
body.present?
end
end
|
#html ⇒ Object
49
50
51
|
# File 'app/models/pulitzer/content_element.rb', line 49
def html
body.blank? ? "" : body.html_safe
end
|
#style_display ⇒ Object
109
110
111
|
# File 'app/models/pulitzer/content_element.rb', line 109
def style_display
style&.display_name
end
|
#style_options ⇒ Object
105
106
107
|
# File 'app/models/pulitzer/content_element.rb', line 105
def style_options
post_type_content_element_type.styles
end
|
#video_link ⇒ Object
43
44
45
46
47
|
# File 'app/models/pulitzer/content_element.rb', line 43
def video_link
if video_type? && !body.nil?
vimeo_video(body) || youtube_video(body)
end
end
|