Class: RepresentationPolicy

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

Overview

Protects Representation objects

Instance Method Summary collapse

Methods inherited from ApplicationPolicy

#initialize, #scope, #user

Constructor Details

This class inherits a constructor from ApplicationPolicy

Instance Method Details

#create?Boolean Also known as: new?

Returns whether or not the user can create representations for this organization

Returns:

  • (Boolean)

    whether or not the user can create representations for this organization



16
17
18
# File 'app/policies/representation_policy.rb', line 16

def create?
  organization_user.author?
end

#index?true

Returns everyone can list representations in their organizations

Returns:

  • (true)

    everyone can list representations in their organizations



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

def index?
  true
end

#show?true

Returns anyone can view an representation belonging to their organization

Returns:

  • (true)

    anyone can view an representation belonging to their organization



11
12
13
# File 'app/policies/representation_policy.rb', line 11

def show?
  true
end

#update?Boolean Also known as: edit?, destroy?

Returns if the user can change the representation

Returns:

  • (Boolean)

    if the user can change the representation



23
24
25
26
# File 'app/policies/representation_policy.rb', line 23

def update?
  return true if organization_user.editor?
  organization_user.author? && organization_user == record.author
end