Class: Ability

Inherits:
ApplicationRecord show all
Includes:
CommunityRelated
Defined in:
app/models/ability.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

#attributes_print, fuzzy_search, match_search, #match_search, sanitize_for_search, sanitize_name, sanitize_sql_in, useful_err_msg, with_lax_group_rules

Class Method Details

.[](key) ⇒ Object



25
26
27
# File 'app/models/ability.rb', line 25

def self.[](key)
  find_by internal_id: key
end

.on_user(user) ⇒ Object



10
11
12
# File 'app/models/ability.rb', line 10

def self.on_user(user)
  Ability.where(id: UserAbility.where(community_user: user.community_user).select(:ability_id).distinct)
end

.trust_levelsObject



14
15
16
17
18
19
20
21
22
23
# File 'app/models/ability.rb', line 14

def self.trust_levels
  {
    0 => 'everyone',
    1 => 'anyone with a user account',
    2 => 'all but new users',
    3 => 'veteran users',
    4 => 'moderators only',
    5 => 'staff only'
  }
end

Instance Method Details

#manual?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'app/models/ability.rb', line 6

def manual?
  post_score_threshold.nil? && edit_score_threshold.nil? && flag_score_threshold.nil?
end