Class: UserPolicy

Inherits:
Policy show all
Defined in:
app/policies/user_policy.rb

Instance Attribute Summary

Attributes inherited from Policy

#record, #user

Instance Method Summary collapse

Methods inherited from Policy

collection, for, #initialize, member

Methods included from Policy::DefaultPolicy

#index, #update?

Constructor Details

This class inherits a constructor from Policy

Instance Method Details

#change_password?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'app/policies/user_policy.rb', line 48

def change_password?
  user == record
end

#create?Boolean

Returns:

  • (Boolean)


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

def create?
  new?
end

#deactivated?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'app/policies/user_policy.rb', line 8

def deactivated?
  index?
end

#delete_image?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'app/policies/user_policy.rb', line 36

def delete_image?
  edit?
end

#destroy?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'app/policies/user_policy.rb', line 44

def destroy?
  user.role?(:users)
end

#edit?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'app/policies/user_policy.rb', line 28

def edit?
  user == record || user.role?(:users)
end

#index?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'app/policies/user_policy.rb', line 4

def index?
  true
end

#login?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'app/policies/user_policy.rb', line 20

def login?
  true
end

#manage?Boolean

Returns:

  • (Boolean)


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

def manage?
  new?
end

#new?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'app/policies/user_policy.rb', line 12

def new?
  User.none? || user.role?(:users)
end

#policies?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'app/policies/user_policy.rb', line 40

def policies?
  user.role?(:users)
end

#show?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'app/policies/user_policy.rb', line 32

def show?
  edit?
end