Class: ApplicationPolicy

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

Defined Under Namespace

Classes: Scope

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, record) ⇒ ApplicationPolicy

Returns a new instance of ApplicationPolicy.


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

def initialize(user, record)
  @user = user
  @record = record
end

Instance Attribute Details

#recordObject (readonly)

Returns the value of attribute record


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

def record
  @record
end

#userObject (readonly)

Returns the value of attribute user


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

def user
  @user
end

Instance Method Details

#create?Boolean

Returns:

  • (Boolean)

13
# File 'app/policies/application_policy.rb', line 13

def create? ; editor?                                 ; end

#destroy?Boolean

Returns:

  • (Boolean)

17
# File 'app/policies/application_policy.rb', line 17

def destroy?; editor?                                 ; end

#edit?Boolean

Returns:

  • (Boolean)

16
# File 'app/policies/application_policy.rb', line 16

def edit?   ; update?                                 ; end

#index?Boolean

The General Application policy is let editing to editors.

Returns:

  • (Boolean)

11
# File 'app/policies/application_policy.rb', line 11

def index?  ; true                                    ; end

#new?Boolean

Returns:

  • (Boolean)

14
# File 'app/policies/application_policy.rb', line 14

def new?    ; create?                                 ; end

#scopeObject


18
# File 'app/policies/application_policy.rb', line 18

def scope   ; Pundit.policy_scope!(user, record.class); end

#show?Boolean

Returns:

  • (Boolean)

12
# File 'app/policies/application_policy.rb', line 12

def show?   ; scope.where(:id => record.id).exists?   ; end

#update?Boolean

Returns:

  • (Boolean)

15
# File 'app/policies/application_policy.rb', line 15

def update? ; editor?                                 ; end