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



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

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

Instance Method Details

#all_element_typesObject



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

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)


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

def has_free_form_sections?
  free_form_section_types.any?
end

#has_templated_content_elements?Boolean

Returns:

  • (Boolean)


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

def has_templated_content_elements?
  content_element_types.any?
end

#highest_element_sortObject



46
47
48
49
# File 'app/models/pulitzer/post_type.rb', line 46

def highest_element_sort
  last_element = all_element_types.max_by{ |e| e.sort_order || 0}
  last_element&.sort_order || 0
end

#singleton_postObject



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

def singleton_post
  posts.first
end

#singleton_post?Boolean

Returns:

  • (Boolean)


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

def singleton_post?
  !plural
end

#singular?Boolean

Returns:

  • (Boolean)


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

def singular?
  !plural
end