Class: ForumPage
- Inherits:
-
Page
- Object
- Page
- ForumPage
- Defined in:
- app/models/forum_page.rb
Instance Attribute Summary collapse
-
#forum ⇒ Object
Returns the value of attribute forum.
-
#post ⇒ Object
Returns the value of attribute post.
-
#topic ⇒ Object
Returns the value of attribute topic.
Instance Method Summary collapse
- #cache? ⇒ Boolean
- #find_by_path(path, live = true, clean = true) ⇒ Object
- #forums ⇒ Object
- #posts ⇒ Object
- #read_parameters(path) ⇒ Object
- #topics ⇒ Object
Instance Attribute Details
#forum ⇒ Object
Returns the value of attribute forum.
2 3 4 |
# File 'app/models/forum_page.rb', line 2 def forum @forum end |
#post ⇒ Object
Returns the value of attribute post.
2 3 4 |
# File 'app/models/forum_page.rb', line 2 def post @post end |
#topic ⇒ Object
Returns the value of attribute topic.
2 3 4 |
# File 'app/models/forum_page.rb', line 2 def topic @topic end |
Instance Method Details
#cache? ⇒ Boolean
7 8 9 |
# File 'app/models/forum_page.rb', line 7 def cache? !restricted? end |
#find_by_path(path, live = true, clean = true) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'app/models/forum_page.rb', line 11 def find_by_path(path, live = true, clean = true) path = clean_path(path) if clean my_path = self.path_without_parts if path =~ /^#{Regexp.quote(my_path)}(.*)/ read_parameters($1) self else nil end end |
#forums ⇒ Object
37 38 39 |
# File 'app/models/forum_page.rb', line 37 def forums Forum.visible_to(Reader.current) end |
#posts ⇒ Object
43 44 45 |
# File 'app/models/forum_page.rb', line 43 def posts Post.visible_to(Reader.current) end |
#read_parameters(path) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/models/forum_page.rb', line 22 def read_parameters(path) unless path.blank? parts = path.split(/\/+/) if forum_id = parts.pop forum = Forum.find(@forum_id) if topic_id = parts.pop topic = forum.topics.find(@topic_id) if post_id = parts.pop post = topic.posts.find(@topic_id) end end end end end |
#topics ⇒ Object
40 41 42 |
# File 'app/models/forum_page.rb', line 40 def topics Topic.visible_to(Reader.current) end |