Class: ProblemPolicy

Inherits:
ApplicationPolicy show all
Defined in:
app/policies/problem_policy.rb

Defined Under Namespace

Classes: Scope

Constant Summary

Constants inherited from ApplicationPolicy

ApplicationPolicy::STANDARD_EDIT_PERMISSIONS, ApplicationPolicy::STANDARD_VIEW_PERMISSIONS

Instance Attribute Summary

Attributes inherited from ApplicationPolicy

#record, #user

Instance Method Summary collapse

Methods inherited from ApplicationPolicy

#create?, #destroy?, #destroy_all?, #edit?, #initialize, #new?, #update?

Constructor Details

This class inherits a constructor from ApplicationPolicy

Instance Method Details

#index? ⇒ Boolean

Returns:

  • (Boolean)


2
3
4
# File 'app/policies/problem_policy.rb', line 2

def index?
  user&.is_moderator?
end

#resolve? ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
# File 'app/policies/problem_policy.rb', line 10

def resolve?
  all_of(
    user&.is_moderator?,
    Pundit::PolicyFinder.new(record.problematic).policy.new(user, record.problematic).send(:"#{record.resolution_strategy}?")
  )
end

#show? ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
# File 'app/policies/problem_policy.rb', line 6

def show?
  user&.is_moderator?
end