Class: Pulitzer::PostTypeContentElementType
Constant Summary
collapse
- Any_clickable =
OpenStruct.new
- URL_clickable =
OpenStruct.new
Class Method Summary
collapse
Instance Method Summary
collapse
#handle_sort_order, #highest_sibling_sort, included
assoc_name, attrs_name, convert_hash_to_nested
Class Method Details
.clickable_kinds ⇒ Object
.convert_nested_assoc(json_hash) ⇒ Object
38
39
40
41
42
43
|
# File 'app/models/pulitzer/post_type_content_element_type.rb', line 38
def self.convert_nested_assoc(json_hash)
json_hash[attrs_name].map!{|ptcet_attrs|
new_attrs = Pulitzer::Style.convert_hash_to_nested ptcet_attrs
}
json_hash
end
|
.export_config ⇒ Object
29
30
31
32
33
34
35
36
|
# File 'app/models/pulitzer/post_type_content_element_type.rb', line 29
def self.export_config
{
except: [:id, :post_type_version_id],
include: {
styles: { except: :id }
}
}
end
|
Instance Method Details
#any_clickable_kind? ⇒ Boolean
53
54
55
|
# File 'app/models/pulitzer/post_type_content_element_type.rb', line 53
def any_clickable_kind?
'any' == clickable_kind
end
|
#clickable_kind_display ⇒ Object
49
50
51
|
# File 'app/models/pulitzer/post_type_content_element_type.rb', line 49
def clickable_kind_display
GlobalID::Locator.locate(clickable_kind)&.name || clickable_kind.humanize
end
|
#clickable_kinds ⇒ Object
#clone_me ⇒ Object
103
104
105
106
107
108
|
# File 'app/models/pulitzer/post_type_content_element_type.rb', line 103
def clone_me
clone_attrs = self.attributes.dup
clone_attrs.delete 'id'
clone_attrs.delete 'post_type_version_id'
Pulitzer::PostTypeContentElementType.new(clone_attrs)
end
|
#custom_clickable_kinds ⇒ Object
65
66
67
|
# File 'app/models/pulitzer/post_type_content_element_type.rb', line 65
def custom_clickable_kinds
Pulitzer::CustomOptionList.all.to_a
end
|
#custom_option_list ⇒ Object
69
70
71
|
# File 'app/models/pulitzer/post_type_content_element_type.rb', line 69
def custom_option_list
GlobalID::Locator.locate(clickable_kind)
end
|
#custom_options ⇒ Object
73
74
75
|
# File 'app/models/pulitzer/post_type_content_element_type.rb', line 73
def custom_options
custom_option_list&.custom_options
end
|
#first_style ⇒ Object
99
100
101
|
# File 'app/models/pulitzer/post_type_content_element_type.rb', line 99
def first_style
styles.first
end
|
#text_editor_display ⇒ Object
90
91
92
93
94
95
96
97
|
# File 'app/models/pulitzer/post_type_content_element_type.rb', line 90
def text_editor_display
case text_editor
when 'None'
'no editor'
else
text_editor
end
end
|
#type_specific_display ⇒ Object
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'app/models/pulitzer/post_type_content_element_type.rb', line 77
def type_specific_display
case type
when :image
"#{height}x#{width}"
when :text
text_editor_display
when :clickable
clickable_kind_display
else
''
end
end
|
#url_clickable_kind? ⇒ Boolean
57
58
59
|
# File 'app/models/pulitzer/post_type_content_element_type.rb', line 57
def url_clickable_kind?
'url' == clickable_kind
end
|