Module: Plutonium::Core::Controllers::EntityScoping

Extended by:
ActiveSupport::Concern
Included in:
Plutonium::Core::Controller
Defined in:
lib/plutonium/core/controllers/entity_scoping.rb

Overview

EntityScoping module provides functionality for scoping controllers to specific entities.

This module is designed to be included in controllers that need to operate within the context of a specific entity, such as a user’s organization or a project.

Examples:

Usage in a controller

class MyController < ApplicationController
  include Plutonium::Core::Controllers::EntityScoping
end

Instance Method Summary collapse

Instance Method Details

#scoped_entity_classClass

Returns the class of the scoped entity.

Raises:

  • (NotImplementedError)

    if not scoped to an entity



55
56
57
58
# File 'lib/plutonium/core/controllers/entity_scoping.rb', line 55

def scoped_entity_class
  ensure_legal_entity_scoping_method_access!(__method__)
  current_engine.scoped_entity_class
end

#scoped_entity_param_keySymbol

Returns the parameter key used for entity scoping.

Raises:

  • (NotImplementedError)

    if not scoped to an entity



41
42
43
44
# File 'lib/plutonium/core/controllers/entity_scoping.rb', line 41

def scoped_entity_param_key
  ensure_legal_entity_scoping_method_access!(__method__)
  current_engine.scoped_entity_param_key
end

#scoped_entity_route_keyObject



46
47
48
49
# File 'lib/plutonium/core/controllers/entity_scoping.rb', line 46

def scoped_entity_route_key
  ensure_legal_entity_scoping_method_access!(__method__)
  current_engine.scoped_entity_route_key
end

#scoped_entity_strategySymbol

Returns the strategy used for entity scoping.



33
34
35
# File 'lib/plutonium/core/controllers/entity_scoping.rb', line 33

def scoped_entity_strategy
  current_engine.scoped_entity_strategy
end

#scoped_to_entity?Boolean

Checks if the current engine is scoped to an entity.



26
27
28
# File 'lib/plutonium/core/controllers/entity_scoping.rb', line 26

def scoped_to_entity?
  current_engine.scoped_to_entity?
end