Class: Pulitzer::PostTypeVersion
- Inherits:
-
ApplicationRecord
show all
- Includes:
- ForeignOffice::Broadcaster, StateMachine::Model
- Defined in:
- app/models/pulitzer/post_type_version.rb
Defined Under Namespace
Classes: Preview, Publish, Retire
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
assoc_name, attrs_name, convert_hash_to_nested
Instance Attribute Details
#finished_processing ⇒ Object
Returns the value of attribute finished_processing.
20
21
22
|
# File 'app/models/pulitzer/post_type_version.rb', line 20
def finished_processing
@finished_processing
end
|
#processed_element_count ⇒ Object
Returns the value of attribute processed_element_count.
20
21
22
|
# File 'app/models/pulitzer/post_type_version.rb', line 20
def processed_element_count
@processed_element_count
end
|
Class Method Details
.convert_nested_assoc(json_hash) ⇒ Object
Instance Method Details
#all_element_types ⇒ Object
90
91
92
|
# File 'app/models/pulitzer/post_type_version.rb', line 90
def all_element_types
(post_type_content_element_types.to_a + free_form_section_types.to_a)
end
|
#arity_display ⇒ Object
74
75
76
|
# File 'app/models/pulitzer/post_type_version.rb', line 74
def arity_display
plural? ? 'Many Posts' : 'Single Post'
end
|
#full_name ⇒ Object
58
59
60
|
# File 'app/models/pulitzer/post_type_version.rb', line 58
def full_name
"\"#{name}\" v#{version_number}"
end
|
#has_display? ⇒ Boolean
78
79
80
|
# File 'app/models/pulitzer/post_type_version.rb', line 78
def has_display?
background_styles.any? || justification_styles.any? || sequence_flow_styles.any? || arrangement_styles.any?
end
|
86
87
88
|
# File 'app/models/pulitzer/post_type_version.rb', line 86
def has_free_form_sections?
free_form_section_types.any?
end
|
#has_templated_content_elements? ⇒ Boolean
82
83
84
|
# File 'app/models/pulitzer/post_type_version.rb', line 82
def has_templated_content_elements?
content_element_types.any?
end
|
#highest_element_sort ⇒ Object
94
95
96
97
|
# File 'app/models/pulitzer/post_type_version.rb', line 94
def highest_element_sort
last_element = all_element_types.max_by{ |e| e.sort_order || 0}
last_element&.sort_order || 0
end
|
#locked? ⇒ Boolean
99
100
101
|
# File 'app/models/pulitzer/post_type_version.rb', line 99
def locked?
published? || retired?
end
|
#published_posts_count ⇒ Object
127
128
129
|
# File 'app/models/pulitzer/post_type_version.rb', line 127
def published_posts_count
post_type.published_type_version.posts.count
end
|
#serialize ⇒ Object
121
122
123
124
125
|
# File 'app/models/pulitzer/post_type_version.rb', line 121
def serialize
self.attributes.merge \
processed_element_count: self.processed_element_count,
finished_processing: self.finished_processing
end
|
#singleton_post ⇒ Object
66
67
68
|
# File 'app/models/pulitzer/post_type_version.rb', line 66
def singleton_post
posts.first
end
|
#singleton_post? ⇒ Boolean
70
71
72
|
# File 'app/models/pulitzer/post_type_version.rb', line 70
def singleton_post?
!plural
end
|
#singular? ⇒ Boolean
62
63
64
|
# File 'app/models/pulitzer/post_type_version.rb', line 62
def singular?
!plural
end
|
#state_change ⇒ Object
110
111
112
113
114
115
|
# File 'app/models/pulitzer/post_type_version.rb', line 110
def state_change
{'incomplete' => :preview,
'preview' => :publish,
'published' => :retire,
'retired' => :publish}[status]
end
|
#state_change_display ⇒ Object
117
118
119
|
# File 'app/models/pulitzer/post_type_version.rb', line 117
def state_change_display
state_change.to_s.humanize
end
|
#status_display ⇒ Object
103
104
105
106
107
108
|
# File 'app/models/pulitzer/post_type_version.rb', line 103
def status_display
{'incomplete' => 'Not Ready',
'preview' => 'Previewing',
'published' => 'Published',
'retired' => 'Retired'}[status]
end
|