Class: Pulitzer::PostType

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/pulitzer/post_type.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.named(label) ⇒ Object



15
16
17
# File 'app/models/pulitzer/post_type.rb', line 15

def self.named(label)
  self.find_by(name: label)
end

Instance Method Details

#all_element_typesObject



39
40
41
# File 'app/models/pulitzer/post_type.rb', line 39

def all_element_types
  (post_type_content_element_types.to_a + free_form_section_types.to_a)
end

#has_free_form_sections?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'app/models/pulitzer/post_type.rb', line 35

def has_free_form_sections?
  free_form_section_types.any?
end

#has_templated_content_elements?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'app/models/pulitzer/post_type.rb', line 31

def has_templated_content_elements?
  content_element_types.any?
end

#highest_element_sortObject



43
44
45
46
# File 'app/models/pulitzer/post_type.rb', line 43

def highest_element_sort
  last_element = all_element_types.max_by(&:sort_order)
  last_element&.sort_order || 0
end

#singleton_postObject



23
24
25
# File 'app/models/pulitzer/post_type.rb', line 23

def singleton_post
  posts.first
end

#singleton_post?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'app/models/pulitzer/post_type.rb', line 27

def singleton_post?
  !plural
end

#singular?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'app/models/pulitzer/post_type.rb', line 19

def singular?
  !plural
end