Class: Section
- Includes:
- HasOptions, HasPermalink
- Defined in:
- app/models/section.rb
Direct Known Subclasses
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
TODO validates_inclusion_of :contents_per_page, :in => 1..30, :message => “can only be between 1 and 30.”.
- #type ⇒ Object
Methods included from HasPermalink
Methods included from HasOptions
Class Method Details
.register_type(type) ⇒ Object
13 14 15 |
# File 'app/models/section.rb', line 13 def self.register_type(type) types.push(type) unless types.include?(type) end |
Instance Method Details
#nav_children ⇒ Object
95 96 97 |
# File 'app/models/section.rb', line 95 def nav_children contents.roots.published end |
#owner ⇒ Object
59 60 61 |
# File 'app/models/section.rb', line 59 def owner site end |
#owners ⇒ Object
55 56 57 |
# File 'app/models/section.rb', line 55 def owners owner.owners << owner end |
#published=(published) ⇒ Object
79 80 81 82 83 84 85 |
# File 'app/models/section.rb', line 79 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
87 88 89 90 91 92 |
# File 'app/models/section.rb', line 87 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
71 72 73 |
# File 'app/models/section.rb', line 71 def root_section? self == site.sections.root end |
#state ⇒ Object
75 76 77 |
# File 'app/models/section.rb', line 75 def state published? ? :published : :pending end |
#tag_counts ⇒ Object
67 68 69 |
# File 'app/models/section.rb', line 67 def tag_counts Content.tag_counts :conditions => "section_id = #{id}" end |
#to_param ⇒ Object
TODO validates_inclusion_of :contents_per_page, :in => 1..30, :message => “can only be between 1 and 30.”
51 52 53 |
# File 'app/models/section.rb', line 51 def to_param permalink end |
#type ⇒ Object
63 64 65 |
# File 'app/models/section.rb', line 63 def type read_attribute(:type) || 'Section' end |