Sha256: 6c606b33de0b3c12cd4081593ad5407e9d61be62a8b8f8647e45ce1e5ed3a90f

Contents?: true

Size: 1.56 KB

Versions: 13

Compression:

Stored size: 1.56 KB

Contents

# frozen_string_literal: true

module Maquina
  ##
  # 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.

  class PlanPolicy < ApplicationPolicy
    def index?
      management?
    end

    def new?
      management?
    end

    def create?
      new?
    end

    def edit?
      management?
    end

    private

    relation_scope do |scope|
      scope
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
maquina-0.7.2 app/policies/maquina/plan_policy.rb
maquina-0.7.1 app/policies/maquina/plan_policy.rb
maquina-0.5.2 app/policies/maquina/plan_policy.rb
maquina-0.5.1 app/policies/maquina/plan_policy.rb
maquina-0.4.0 app/policies/maquina/plan_policy.rb
maquina-0.3.0 app/policies/maquina/plan_policy.rb
maquina-0.2.5 app/policies/maquina/plan_policy.rb
maquina-0.2.4 app/policies/maquina/plan_policy.rb
maquina-0.2.3 app/policies/maquina/plan_policy.rb
maquina-0.2.2 app/policies/maquina/plan_policy.rb
maquina-0.2.1 app/policies/maquina/plan_policy.rb
maquina-0.2.0 app/policies/maquina/plan_policy.rb
maquina-0.1.0 app/policies/maquina/plan_policy.rb