Class: UserPolicy

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(current_user, model) ⇒ UserPolicy

Returns a new instance of UserPolicy.


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

def initialize(current_user, model)
  @current_user = current_user
  @user = model
end

Instance Attribute Details

#current_userObject (readonly)

Returns the value of attribute current_user


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

def current_user
  @current_user
end

#modelObject (readonly)

Returns the value of attribute model


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

def model
  @model
end

Instance Method Details

#destroy?Boolean

Returns:

  • (Boolean)

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

def destroy?
  return false if @current_user == @user
  @current_user.admin?
end

#finish_signup?Boolean

Returns:

  • (Boolean)

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

def finish_signup?
	@current_user.admin? or @current_user == @user
end

#identities?Boolean

Returns:

  • (Boolean)

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

def identities?
	@current_user == @user
end

#index?Boolean

Returns:

  • (Boolean)

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

def index?
  @current_user.admin?
end

#show?Boolean

Returns:

  • (Boolean)

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

def show?
  @current_user.admin? or @current_user == @user
end

#update?Boolean

Returns:

  • (Boolean)

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

def update?
  @current_user.admin?
end