Class: ForumPage

Inherits:
Page
  • Object
show all
Defined in:
app/models/forum_page.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#forumObject

Returns the value of attribute forum.



2
3
4
# File 'app/models/forum_page.rb', line 2

def forum
  @forum
end

#postObject

Returns the value of attribute post.



2
3
4
# File 'app/models/forum_page.rb', line 2

def post
  @post
end

#topicObject

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

Returns:

  • (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

#forumsObject



37
38
39
# File 'app/models/forum_page.rb', line 37

def forums
  Forum.visible_to(Reader.current)
end

#postsObject



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

#topicsObject



40
41
42
# File 'app/models/forum_page.rb', line 40

def topics
  Topic.visible_to(Reader.current)
end