Class: Section
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Section
- Includes:
- Adva::HasOptions, Adva::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 Adva::HasPermalink
Methods included from Adva::HasOptions
Class Method Details
.register_type(type) ⇒ Object
9 10 11 |
# File 'app/models/section.rb', line 9 def self.register_type(type) types.push(type) unless types.include?(type) end |
Instance Method Details
#nav_children ⇒ Object
94 95 96 |
# File 'app/models/section.rb', line 94 def nav_children contents.roots.published end |
#owner ⇒ Object
58 59 60 |
# File 'app/models/section.rb', line 58 def owner site end |
#owners ⇒ Object
54 55 56 |
# File 'app/models/section.rb', line 54 def owners owner.owners << owner end |
#published=(published) ⇒ Object
78 79 80 81 82 83 84 |
# File 'app/models/section.rb', line 78 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
86 87 88 89 90 91 |
# File 'app/models/section.rb', line 86 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
70 71 72 |
# File 'app/models/section.rb', line 70 def root_section? self == site.sections.root end |
#state ⇒ Object
74 75 76 |
# File 'app/models/section.rb', line 74 def state published? ? :published : :pending end |
#tag_counts ⇒ Object
66 67 68 |
# File 'app/models/section.rb', line 66 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.”
50 51 52 |
# File 'app/models/section.rb', line 50 def to_param permalink end |
#type ⇒ Object
62 63 64 |
# File 'app/models/section.rb', line 62 def type read_attribute(:type) || 'Section' end |