Class: Maquina::PlanPolicy

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

Overview

A class representing the authorization policy for the Plan model.

Methods

  • index?

    Returns true if the user has authorization to view the index page for Plan model.

  • new?

    Returns true if the user has authorization to view the new page for creating a new Plan object.

  • create?

    Returns the same result as new?, as it requires the same authorization to create a new Plan object.

  • edit?

    Returns true if the user has authorization to view the edit page for an existing Plan object.

  • relation_scope

    Provides a relation scope for Plan model, allowing customization of query scopes based on authorization policies.

Private Methods

  • management?

    Helper method to determine if the user is in a management role. This method exists in Maquina::ApplicationPolicy.

Usage

To use PlanPolicy, define the relevant authorization methods, such as management? or any other custom authorization methods, in the Maquina module or in a related authorization system. Then, inherit from PlanPolicy in your Plan model’s policy class, and use the provided authorization methods, such as index?, new?, create?, and edit?, to define the authorization policies for Plan model actions.

Instance Method Summary collapse

Methods inherited from ApplicationPolicy

#destroy?, #new_modal?, #show?, #update?

Instance Method Details

#create?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'app/policies/maquina/plan_policy.rb', line 35

def create?
  new?
end

#edit?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'app/policies/maquina/plan_policy.rb', line 39

def edit?
  management?
end

#index?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'app/policies/maquina/plan_policy.rb', line 27

def index?
  management?
end

#new?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'app/policies/maquina/plan_policy.rb', line 31

def new?
  management?
end