Class: Section
- Defined in:
- app/models/section.rb
Direct Known Subclasses
Constant Summary collapse
- @@types =
['Page']
Class Method Summary collapse
Instance Method Summary collapse
- #nav_children ⇒ Object
- #owner ⇒ Object
- #owners ⇒ Object
- #published=(published) ⇒ Object
- #published?(parents = false) ⇒ Boolean (also: #published)
- #root_section? ⇒ Boolean
- #state ⇒ Object
- #tag_counts ⇒ Object
- #to_param ⇒ Object
- #type ⇒ Object
Class Method Details
.register_type(type) ⇒ Object
42 43 44 45 |
# File 'app/models/section.rb', line 42 def register_type(type) @@types << type @@types.uniq! end |
Instance Method Details
#nav_children ⇒ Object
92 93 94 |
# File 'app/models/section.rb', line 92 def nav_children contents.roots.published end |
#owner ⇒ Object
56 57 58 |
# File 'app/models/section.rb', line 56 def owner site end |
#owners ⇒ Object
52 53 54 |
# File 'app/models/section.rb', line 52 def owners owner.owners << owner end |
#published=(published) ⇒ Object
76 77 78 79 80 81 82 |
# File 'app/models/section.rb', line 76 def published=(published) if published.to_i == 1 self.published_at = Time.current if !published_at elsif published.to_i == 0 self.published_at = nil end end |
#published?(parents = false) ⇒ Boolean Also known as: published
84 85 86 87 88 89 |
# File 'app/models/section.rb', line 84 def published?(parents = false) return true if self == site.sections.root # the root section is always published return false if parents && has_unpublished_ancestor? return false if published_at.nil? || published_at > Time.current return true end |
#root_section? ⇒ Boolean
68 69 70 |
# File 'app/models/section.rb', line 68 def root_section? self == site.sections.root end |
#state ⇒ Object
72 73 74 |
# File 'app/models/section.rb', line 72 def state published? ? :published : :pending end |
#tag_counts ⇒ Object
64 65 66 |
# File 'app/models/section.rb', line 64 def tag_counts Content.tag_counts :conditions => "section_id = #{id}" end |
#to_param ⇒ Object
48 49 50 |
# File 'app/models/section.rb', line 48 def to_param permalink end |
#type ⇒ Object
60 61 62 |
# File 'app/models/section.rb', line 60 def type read_attribute(:type) || 'Section' end |