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)

46
47
48
# File 'app/policies/user_policy.rb', line 46

def change_password?
  user == record
end

#create?Boolean

Returns:

  • (Boolean)

14
15
16
# File 'app/policies/user_policy.rb', line 14

def create?
  new?
end

#deactivated?Boolean

Returns:

  • (Boolean)

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

def deactivated?
  index?
end

#delete_image?Boolean

Returns:

  • (Boolean)

34
35
36
# File 'app/policies/user_policy.rb', line 34

def delete_image?
  edit?
end

#destroy?Boolean

Returns:

  • (Boolean)

42
43
44
# File 'app/policies/user_policy.rb', line 42

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

#edit?Boolean

Returns:

  • (Boolean)

26
27
28
# File 'app/policies/user_policy.rb', line 26

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

#index?Boolean

Returns:

  • (Boolean)

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

def index?
  true
end

#login?Boolean

Returns:

  • (Boolean)

18
19
20
# File 'app/policies/user_policy.rb', line 18

def login?
  true
end

#manage?Boolean

Returns:

  • (Boolean)

22
23
24
# File 'app/policies/user_policy.rb', line 22

def manage?
  new?
end

#new?Boolean

Returns:

  • (Boolean)

10
11
12
# File 'app/policies/user_policy.rb', line 10

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

#policies?Boolean

Returns:

  • (Boolean)

38
39
40
# File 'app/policies/user_policy.rb', line 38

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

#show?Boolean

Returns:

  • (Boolean)

30
31
32
# File 'app/policies/user_policy.rb', line 30

def show?
  edit?
end