Module: BlogPost::CommentSetting

Defined in:
app/models/blog_post.rb

Overview

Added module for settings

Class Method Summary collapse

Class Method Details

.do_commentableObject

this method update the comments_allowed value to true



104
105
106
# File 'app/models/blog_post.rb', line 104

def do_commentable
  Setting.blog_commentable_setting
end

.do_moderatableObject

this method update the comments_allowed value to true



114
115
116
# File 'app/models/blog_post.rb', line 114

def do_moderatable
  Setting.blog_moderatable_setting
end

.do_uncommentableObject

this method update the comments_allowed value to false



99
100
101
# File 'app/models/blog_post.rb', line 99

def do_uncommentable
  Setting.blog_uncommentable_setting
end

.do_unmoderatableObject

this method update the comments_allowed value to false



109
110
111
# File 'app/models/blog_post.rb', line 109

def do_unmoderatable
  Setting.blog_unmoderatable_setting
end

.is_comments_allowed?Boolean

this method returns true if comments_allowed value is true or 1 neither false in settings table

Returns:

  • (Boolean)


79
80
81
82
83
84
85
86
# File 'app/models/blog_post.rb', line 79

def is_comments_allowed?
  value = Setting.find_by_name('comment_allowed').value
   if value.to_i == 1
     return true
   else
     return false
   end
end

.is_comments_moderated?Boolean

this method returns true if comments_moderated value is true or 1 neither false in settings table

Returns:

  • (Boolean)


89
90
91
92
93
94
95
96
# File 'app/models/blog_post.rb', line 89

def is_comments_moderated?
  value = Setting.find_by_name('comment_moderation').value
  if value.to_i == 1
     true
   else
     false
   end
end