Skip to content

Commit 7f69f68

Browse files
committed
added a bunch of YARD comments for methods
1 parent 38ad693 commit 7f69f68

File tree

6 files changed

+23
-1
lines changed

6 files changed

+23
-1
lines changed

app/controllers/application_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ def enforce_signed_in
318318
path.start_with?('/assets/') ||
319319
path.end_with?('.css') || path.end_with?('.js')
320320

321-
# Make available to controller that the we should not leak posts in the sidebar
321+
# Used by derived controllers to avoid leaking featured posts to the sidebar
322322
@prevent_sidebar = true
323323

324324
# Allow /help (help center), /help/* and /policy/* depending on settings

app/controllers/posts_controller.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,9 @@ def unless_locked
725725
check_if_locked(@post)
726726
end
727727

728+
# Attempts to actually delete a post draft
729+
# @param path [String] draft path to delete
730+
# @return [Boolean] status of the operation
728731
def do_draft_delete(path)
729732
keys = [:body, :comment, :excerpt, :license, :saved_at, :tags, :tag_name, :title].map do |key|
730733
pfx = key == :saved_at ? 'saved_post_at' : 'saved_post'

app/models/category.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ def top_level_post_types
4444
post_types.where(is_top_level: true)
4545
end
4646

47+
# Are there new posts for a given user since their last visit?
48+
# @param user [User] user to check
49+
# @return [Boolean] check result
4750
def new_posts_for?(user)
4851
key = "#{community_id}/#{user.id}/#{id}/last_visit"
4952
Rails.cache.fetch key, expires_in: 5.minutes do
@@ -72,6 +75,9 @@ def self.accessible_to(user)
7275
Category.where('IFNULL(min_view_trust_level, -1) <= ?', trust_level)
7376
end
7477

78+
# Gets category matching a given name
79+
# @param name [String] name of the category
80+
# @return [Category, nil]
7581
def self.by_lowercase_name(name)
7682
categories = Rails.cache.fetch 'categories/by_lowercase_name' do
7783
Category.all.to_h { |c| [c.name.downcase, c.id] }
@@ -87,6 +93,9 @@ def self.by_id(id)
8793
categories[id]
8894
end
8995

96+
# Gets a collection of categories matching a given search term
97+
# @param term [String] search term
98+
# @return [ActiveRecord::Relation<Category>]
9099
def self.search(term)
91100
where('name LIKE ?', "%#{sanitize_sql_like(term)}%")
92101
end

app/models/close_reason.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ class CloseReason < ApplicationRecord
77
presence: true,
88
uniqueness: { scope: [:community_id], case_sensitive: false }
99

10+
# Is the close reason network-wide (global)?
11+
# @return [Boolean] check result
1012
def global?
1113
community.nil?
1214
end

app/models/comment_thread.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,16 @@ class CommentThread < ApplicationRecord
1616

1717
after_create :create_follower
1818

19+
# Are there any threads on a given post that a given user follows?
20+
# @param post [Post] post to check
21+
# @param user [User] user to check
22+
# @return [Boolean] check result
1923
def self.post_followed?(post, user)
2024
ThreadFollower.where(post: post, user: user).any?
2125
end
2226

27+
# Is the thread read-only (can't be edited)?
28+
# @return [Boolean] check result
2329
def read_only?
2430
locked? || archived? || deleted?
2531
end

app/models/user_ability.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ class UserAbility < ApplicationRecord
22
belongs_to :community_user
33
belongs_to :ability
44

5+
# Is the ability temporarily or permanently suspended?
6+
# @return [Boolean] check result
57
def suspended?
68
return true if is_suspended && suspension_end.nil? # permanent suspension
79
return true if is_suspended && !suspension_end.past?

0 commit comments

Comments
 (0)