Module: MongoidForums

Defined in:
lib/mongoid_forums/sanitizer.rb,
lib/mongoid_forums.rb,
lib/mongoid_forums/engine.rb,
lib/mongoid_forums/version.rb,
app/models/mongoid_forums/post.rb,
app/models/mongoid_forums/view.rb,
app/models/mongoid_forums/alert.rb,
app/models/mongoid_forums/forum.rb,
app/models/mongoid_forums/group.rb,
app/models/mongoid_forums/topic.rb,
app/models/mongoid_forums/ability.rb,
app/models/mongoid_forums/category.rb,
app/models/mongoid_forums/subscription.rb,
lib/mongoid_forums/default_permissions.rb,
app/helpers/mongoid_forums/posts_helper.rb,
app/helpers/mongoid_forums/forums_helper.rb,
app/helpers/mongoid_forums/topics_helper.rb,
app/models/mongoid_forums/concerns/viewable.rb,
app/helpers/mongoid_forums/admin/base_helper.rb,
app/helpers/mongoid_forums/formatting_helper.rb,
app/helpers/mongoid_forums/admin/users_helper.rb,
app/helpers/mongoid_forums/application_helper.rb,
lib/generators/mongoid_forums/views_generator.rb,
app/helpers/mongoid_forums/admin/forums_helper.rb,
app/helpers/mongoid_forums/admin/groups_helper.rb,
app/controllers/mongoid_forums/posts_controller.rb,
app/models/mongoid_forums/concerns/subscribable.rb,
lib/generators/mongoid_forums/install_generator.rb,
app/controllers/mongoid_forums/forums_controller.rb,
app/controllers/mongoid_forums/topics_controller.rb,
app/controllers/mongoid_forums/redirect_controller.rb,
app/helpers/mongoid_forums/admin/categories_helper.rb,
app/controllers/mongoid_forums/admin/base_controller.rb,
app/controllers/mongoid_forums/admin/users_controller.rb,
app/controllers/mongoid_forums/admin/forums_controller.rb,
app/controllers/mongoid_forums/admin/groups_controller.rb,
app/controllers/mongoid_forums/admin/topics_controller.rb,
app/controllers/mongoid_forums/admin/categories_controller.rb

Overview

Copyright 2011 Ryan Bigg, Philip Arndt and Josh Adams

This code was obtained from: github.com/kultus/forem-2/blob/master/app/models/forem/subscription.rb

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Defined Under Namespace

Modules: Admin, ApplicationHelper, Concerns, DefaultPermissions, FormattingHelper, ForumsHelper, Generators, PostsHelper, TopicsHelper Classes: Ability, Alert, ApplicationController, Category, Engine, Forum, ForumsController, Group, Post, PostsController, RedirectController, Sanitizer, Subscription, Topic, TopicsController, View

Constant Summary collapse

VERSION =
"1.0.7"

Class Method Summary collapse

Class Method Details

.decorate_user_class!Object


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/mongoid_forums.rb', line 15

def decorate_user_class!
  MongoidForums.user_class.class_eval do
    include MongoidForums::DefaultPermissions

    has_many :mongoid_forums_posts, :class_name => "MongoidForums::Post", :foreign_key => "user_id"
    has_many :mongoid_forums_topics, :class_name => "MongoidForums::Topic", :foreign_key => "user_id"

    field :mongoid_admin, type: Boolean, default: false

    def mongoid_forums_admin?
      mongoid_admin
    end unless method_defined? :mongoid_forums_admin

    # Using +to_s+ by default for backwards compatibility
    def forum_display_name
      to_s
    end unless method_defined? :forum_display_name

  end
end

.per_pageObject


36
37
38
# File 'lib/mongoid_forums.rb', line 36

def per_page
  @@per_page || 20
end

.user_classObject


40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/mongoid_forums.rb', line 40

def user_class
  if @@user_class.is_a?(Class)
    raise "You can't set MongoidForums.user_class to be a class. Please use a string instead.\n\n " +
          "See https://github.com/radar/forem/issues/88 for more information."
  elsif @@user_class.is_a?(String)
    begin
      Object.const_get(@@user_class)
    rescue NameError
      @@user_class.constantize
    end
  end
end